不同数量的帖子(WordPress)

时间:2010-01-31 17:10:04

标签: wordpress post loops

我们选择在管理面板中每页显示5个帖子。

我们希望在特定类别中每页显示10个帖子(例如,“projects”width id = 2)。

我们怎么做?

3 个答案:

答案 0 :(得分:1)

将正常循环更改为query post。像

if ( is_category(2) ){

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

//The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post();
   the_content();
endwhile; else:
   echo'Nothing here...';
endif;

//Reset Query
wp_reset_query();

}

答案 1 :(得分:1)

这应仅在主循环中使用。 。如果要在主要对象之外创建单独的循环,则应创建单独的WP_Query对象并改为使用它们。

干杯 巴利马德拉

答案 2 :(得分:1)

我遇到了同样的问题。

这对我有用:

if ( is_category(2) ){
global $query_string;
query_posts( $query_string . "&posts_per_page=500" );