Revision 423 is a pre-publication revision. (Viewing current revision instead.)

Add Disqus comments to any page or template

Taken from this WordPress support thread. Put his in your functions.php file: [php] <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> [/php] Use this in any place where you want the Disqus comments to appear: [php]disqus_embed('THE SHORTNAME OF YOUR DISQUS');[/php]

Revisions

  • April 28, 2013 @ 12:04:17 [Current Revision] by PeterLugg
  • April 28, 2013 @ 12:03:43 by PeterLugg

Revision Differences

April 28, 2013 @ 12:03:43Current Revision
Content
Deleted: Taken from this WordpRess support thread.Added: Taken from this <a href="http:// wordpress.org/ support/topic/ disqus-shortcode" target="_blank" >Wordpress support thread</a>.
Unchanged: Put his in your functions.php file:Unchanged: Put his in your functions.php file:
 Added: [php]
 Added: &lt;pre&gt;&lt; code&gt;function disqus_embed( $disqus_shortname) {
 Added: global $post;
 Added: wp_enqueue_script( 'disqus_embed','http: //'.$disqus_ shortname.'.disqus.com/embed.js');
 Added: echo '&lt;div id=&quot;disqus_ thread&quot;&gt; &lt;/div&gt;
 Added: &lt;script type=&quot;text/ javascript&quot;&gt;
 Added: var disqus_shortname = &quot;'.$disqus_ shortname.'&quot;;
 Added: var disqus_title = &quot;'.$post- &gt;post_title.'&quot;;
 Added: var disqus_url = &quot;'.get_permalink( $post-&gt;ID).'&quot;;
 Added: var disqus_identifier = &quot;'.$disqus_ shortname.'-'.$post- &gt;ID.'&quot;;
 Added: &lt;/script&gt;';
 Added: }&lt;/code&gt; &lt;/pre&gt;
Deleted: [php][/php] Added: [/php]
Unchanged: Use this in any place where you want the Disqus comments to appear:Unchanged: Use this in any place where you want the Disqus comments to appear:
Deleted: [php][/php]Added: [php]disqus_embed('THE SHORTNAME OF YOUR DISQUS');[/php]

Note: Spaces may be added to comparison text to allow better line wrapping.

No comments yet.

Leave a Reply