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
1 Answer
Reset to default 1Integrating 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
1 Answer
Reset to default 1Integrating 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
版权声明:本文标题:How to display Disqus comment count in WordPress? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749149373a2323549.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论