Manually install Disqus on WordPress

If the Disqus WordPress (WP) plugin isn't functioning properly within your theme, you have the alternative option of installing Disqus manually using our Universal Embed code.

The following functionality is not available under the manual installation:

Steps to installing Disqus manually:

Navigate to the theme editor within your WP installation on the Appearance > Editor page.

Appearance > Editor

Locate the 'comments.php' file in the theme files listed on the right side of your screen. Backup this existing code by copy and pasting it into a text-file.

Comments File

Afterwards, replace the code in 'comments.php' with the code snippet below that includes the Universal Embed code with an if statement, which verifies that comments are enabled for the page in question.

Note: Don't forget to change EXAMPLE to your forum's shortname.

<?php if (comments_open()) : ?>
<div id="disqus_thread"></div>
<script>
    /**
     *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
     *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
     */
    /*
    var disqus_config = function () {
        this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
    */
    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');
        
        s.src = '//EXAMPLE.disqus.com/embed.js';
        
        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<?php endif; // comments_open ?>

Using the WordPress 2013 Theme:

In the 2013 default theme for WordPress, you'll need to enable the plugin setting to output the JavaScript in the footer and also add the entry-content class to the disqus_thread div.

Entry Content

Did you find this article helpful?