admin管理员组

文章数量:1130349

I'm using Disqus on my site. The theme that I'm using has comment count shown on every post, but it shows only default WordPress comments system count. How can I integrate it with Disqus, so the comment count would show Disqus comments?

Here's my site -

I'm using Disqus on my site. The theme that I'm using has comment count shown on every post, but it shows only default WordPress comments system count. How can I integrate it with Disqus, so the comment count would show Disqus comments?

Here's my site - http://tophistorie.pl

Share Improve this question asked Nov 26, 2018 at 14:41 kacper3355kacper3355 772 silver badges9 bronze badges 1
  • please see link more information : code.tutsplus/tutorials/… – vikrant zilpe Commented Nov 27, 2018 at 9:25
Add a comment  | 

1 Answer 1

Reset to default 1

Integrating Disqus Into WordPress Without a Plugin As we discussed earlier, doing stuff without plugins helps us optimize our website - a single query is a single query, right? Anyways, here are the functions that we're going to use - like always, add these inside your theme's functions.php file: Embedding Disqus Comments

function disqus_embed($disqus_shortname) {
global $post;
wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus/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>';

}

The function is pretty simple: Use the code <?php disqus_embed('myexampleblog'); ?> anywhere you want in your single.php and page.php files to embed and show Disqus comments for that page. You can search for the comments_template(); function and replace it with our new function, since we're not going to use the native commenting functions anymore.

I'm using Disqus on my site. The theme that I'm using has comment count shown on every post, but it shows only default WordPress comments system count. How can I integrate it with Disqus, so the comment count would show Disqus comments?

Here's my site -

I'm using Disqus on my site. The theme that I'm using has comment count shown on every post, but it shows only default WordPress comments system count. How can I integrate it with Disqus, so the comment count would show Disqus comments?

Here's my site - http://tophistorie.pl

Share Improve this question asked Nov 26, 2018 at 14:41 kacper3355kacper3355 772 silver badges9 bronze badges 1
  • please see link more information : code.tutsplus/tutorials/… – vikrant zilpe Commented Nov 27, 2018 at 9:25
Add a comment  | 

1 Answer 1

Reset to default 1

Integrating Disqus Into WordPress Without a Plugin As we discussed earlier, doing stuff without plugins helps us optimize our website - a single query is a single query, right? Anyways, here are the functions that we're going to use - like always, add these inside your theme's functions.php file: Embedding Disqus Comments

function disqus_embed($disqus_shortname) {
global $post;
wp_enqueue_script('disqus_embed','http://'.$disqus_shortname.'.disqus/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>';

}

The function is pretty simple: Use the code <?php disqus_embed('myexampleblog'); ?> anywhere you want in your single.php and page.php files to embed and show Disqus comments for that page. You can search for the comments_template(); function and replace it with our new function, since we're not going to use the native commenting functions anymore.

本文标签: How to display Disqus comment count in WordPress