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>\';
}
函数非常简单:使用代码<?php disqus_embed(\'myexampleblog\'); ?>
在你的单身生活中,你想去哪里就去哪里。php和页面。php文件嵌入并显示该页面的Disqs注释。您可以搜索comments\\u template();函数并将其替换为新函数,因为我们不再使用本机注释函数。