0

您好,我需要在不同区域回显 WP_Query,以便我可以在每个渲染帖子标题之间添加内容..

所以基本上我想手动突破帖子,这样我就可以将它们放在静态内容周围。希望这是有道理的。

我想做这样的事情。请看我的笔记。

$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) :

    $the_query->the_post();

    echo '<li>' . get_the_title() . '</li>'; // first post title

        //echo 'some static content';

        echo '<li>' . get_the_title() . '</li>'; //second post title

        //echo 'some more static content';

endwhile;
4

1 回答 1

0

您可以使用包含所有静态内容的数组:

$the_query = new WP_Query( $args );

$static_content = array ('content after first post','content after second post');

$counter = 0;

while ( $the_query->have_posts() ) :

    $the_query->the_post();

    echo '<li>' . get_the_title() . '</li>';

    echo $static_content[$counter];

    $counter++;

endwhile;
于 2013-02-11T22:21:21.433 回答