How to display Disqus comment count in WordPress?

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

Topic disqus Wordpress

Category Web


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.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>';

}

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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.