【问题标题】:How do I display the function the_content in this loop?如何在此循环中显示函数 the_content?
【发布时间】:2010-12-18 20:05:35
【问题描述】:

我的 wordpress 网站中有这个循环,它显示带有标题的最新帖子,我想在标题之后显示帖子内容。我通常使用函数 get_the_content 检索它,但我会以各种方式破坏整个页面,我对 php 非常陌生,并且不知道如何将任何内容添加到循环中。这是循环:

     while ( $q_query->have_posts() )
     {

        $q_query->next_post();
        $question = get_post($q_query->post);
        $loophtml = $loophtml . "<li><span class='list-question-title'>" . "<a class='list-answer-link' href='" . get_permalink($question->ID) ."'>" . $question->post_title . "</a></span>";
        $loophtml = $loophtml . "<span class='list-number-answers'>" . get_comments_number($question->ID) . " comentarios</span>&nbsp;&#183;&nbsp<a href='" . get_permalink($question->ID) ."'>Comentar</a>";
        $loophtml = $loophtml . "</li>";
     }

有人知道我如何在某处添加内容吗?谢谢

【问题讨论】:

标签: php wordpress loops


【解决方案1】:

所有post数据都存储在$question对象中,用于检索内容

echo $question->post_content;

Here 是关于 get_post() 的更多信息。

这与您的问题无关,但请注意:next_post() 已弃用。

【讨论】:

  • 抱歉,直到现在我才意识到你对 next_post 的意思。我想更换它,以便将来可以使用。你能告诉我如何替换那条线,所以我不使用 next_post 吗?谢谢
猜你喜欢
  • 2015-05-09
  • 2017-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-04
相关资源
最近更新 更多