我在 WordPress 上使用 disqus 插件时遇到问题。如何在主页上显示disqus。所以单页就是主页,也许就是这样。 有办法解决吗?
谢谢。
最佳答案
我也无法在主页上使用 disqus。 我可以通过设置以下变量来强制comments_template出现: $withcomments = 1;
这使得 comments.php 模板出现,但只有在主页以外的其他页面上时,discus 插件才会启动。
就好像插件本身会阻止它 if is_home() 而不是监听 wp $withcomments 变量
更新
可以使用 disqus.php 插件修复:
在function dsq_comments_template
中更改条件if(!(is_singular() && (have_comments() || 'open' == $post->comment_status ))
在我的例子中,我希望它在主页和自定义分类“问题”的聚合页面上工作,我执行了以下操作:
在全局$comments之后;
为更复杂的条件创建了一个 var(它可以放在 if 中)
$pass = (is_home() || is_taxonomy('issue')) || (is_singular() && ( have_comments() || 'open' == $post->comment_status ));
if(!$pass) {
返回
}
...其余功能...
如果开发者能够针对这种情况做出选择,那就太好了
关于wordpress - 如何在首页显示disqus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5602140/