开发者

How do I display the function the_content in this loop?

开发者 https://www.devze.com 2023-01-31 19:19 出处:网络
I have this loop in my wordpress site which displays the latest posts with their titles, I want to display the post content after the title. I normally retrieve it with the function get_the_content bu

I have this loop in my wordpress site which displays the latest posts with their titles, I want to display the post content after the title. I normally retrieve it with the function get_the_content but I jkeep breaking the whole page in all kind of ways, I'm very new to php and have little idea of how to add anything to the loop. This is the loop:

     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>";
     }

Anyone knows how I add the content somewhere? Thanks


All the post data are stored in the $question object, to retrieve the content

echo $question->post_content;

Here is some more information on get_post().

It has nothing to do with your question but please note: next_post() is deprecated.

0

精彩评论

暂无评论...
验证码 换一张
取 消