Wordpress显示帖子代码没有显示任何帖子

时间:2011-05-24 14:37:19

标签: php wordpress

我使用此代码显示5个帖子(任何帖子都可以)

<div id="featured-post-section">
    <div id="post-list">1
    <?php query_posts( 'posts_per_page=5' ); ?>2

正如你所看到的,我添加了一个1和2个数字....一个在前和后一个......我只得到1 2 ...根本没有帖子显示。

我做错了什么?

1 个答案:

答案 0 :(得分:1)

该功能仅告诉Wordpress要输出多少帖子。您仍然必须使用WP循环实际perform the output

<?php

// The Query
query_posts( 'posts_per_page=5' );

// The Loop
while ( have_posts() ) : the_post();
    echo '<li>';
    the_title();
    echo '</li>';
endwhile;

// Reset Query
wp_reset_query();
相关问题