升序对WordPress循环有奇怪的影响

时间:2012-05-04 作者:Roman Epicnerd Sharf

我有一个自定义循环:

$args = array(
    \'post_type\' => \'symposia_program\',
    \'taxonomy\' => \'days\', 
    \'term\' => \'day-1\',
    \'order\' => \'ASC\'
);

$query = new WP_Query($args);
if ( $query->have_posts() ) :
    while ( $query->have_posts() ) :
        $query->the_post();
        .....(code)....
    endwhile; 
endif;
wp_reset_query();
出于某种原因\'order\' => \'ASC\' 参数对循环的输出有奇怪的影响。基本上它不会呈现一些帖子,即一些最近的帖子。如果我切换回DESC, 所有帖子都显示出来了。请帮忙!

1 个回复
SO网友:Roman Epicnerd Sharf

似乎通过添加\'posts_per_page\' => -1 这迫使WordPress显示与参数匹配的所有帖子。这是我的最终代码:

array ( 
    \'post_type\'      => \'symposia_program\', 
    \'days\'           => $progDay, 
    \'meta_key\'       => \'class_number\', 
    \'orderby\'        => \'meta_value_num\', 
    \'order\'          => \'ASC\', 
    \'posts_per_page\' => -1 
);

结束