【问题标题】:Displaying the Wordpress 'Comments Template' outside the 'loop'在“循环”之外显示 Wordpress 的“评论模板”
【发布时间】:2011-09-17 01:44:13
【问题描述】:

所以我正在构建一个 wordpress 主题,我需要 cmets 从主页上的每个帖子的下拉列表中下来。废话,你必须点击帖子才能看到cmets!当只有一个帖子时,它工作得非常好。它只适用于一篇文章,因为我在循环外显示 cmets 模板。但是对于多个帖子,cmets 模板必须在循环内,但是,当您将 cmets 模板引用放在循环中时,它不会触发,这意味着模板不会显示!

如何让 cmets 模板在循环中显示,以便它出现在主页上的每个帖子上,并且我可以将其设置为下拉菜单?

这是我正在实施它的网站:http://thenozzle.net/ 如果单击“在此处显示 # 评论”,您可以看到它,或者更确切地说,看不到它发生。简单的 php 东西,但我不明白为什么当 cmets 模板引用是 palce din th eloop 时,它不会触发。

这是参考和代码:

<div id="dropdowncomments">
        <?php comments_template(); ?>
</div>

就像我说的,下拉 cmets 是隐藏的,当你点击它时,它会出现,但是 cmets 模板没有加载到 loop.php 中,所以,不好。

有什么帮助吗?

【问题讨论】:

    标签: php comments reference wordpress


    【解决方案1】:

    这很容易(我希望我理解正确)。在the_content() 调用之后,设置$withcomments 变量(全局)并调用comments_template()

    the_content();
    global $withcomments;
    $withcomments = 1;
    comments_template( 'comments.php', true );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-08
      • 1970-01-01
      • 1970-01-01
      • 2015-04-22
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多