$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How to display Disqus comment count in WordPress?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How to display Disqus comment count in WordPress?

matteradmin8PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far