Add Disqus comments to any page or template

Taken from this WordPress support thread.

Put his in your functions.php file:

<pre><code>function disqus_embed($disqus_shortname) {
    global $post;
    wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus.com/embed.js');
    echo '<div id="disqus_thread"></div>
    <script type="text/javascript">
        var disqus_shortname = "'.$disqus_shortname.'";
        var disqus_title = "'.$post->post_title.'";
        var disqus_url = "'.get_permalink($post->ID).'";
        var disqus_identifier = "'.$disqus_shortname.'-'.$post->ID.'";
    </script>';
}</code></pre>

Use this in any place where you want the Disqus comments to appear:

disqus_embed('THE SHORTNAME OF YOUR DISQUS');

Revisions

No comments yet.

Leave a Reply