您发布的链接中的代码将(使用pre_get_posts
) 如果您是从该类型查询帖子,将始终将每页的帖子数更改为3。因此,更好的解决方案是不使用该代码,只需在您的代码上方,然后:
<?php while( have_posts() ) : the_post(); ?>
添加:
if ( get_query_var(\'paged\') )
$paged = get_query_var(\'paged\');
elseif ( get_query_var(\'page\') )
$paged = get_query_var(\'page\');
else
$paged = 1;
query_posts(array(\'post_type\' => \'video\', \'posts_per_page\' => \'3\', \'paged\' => $paged ));
这只会影响该查询,而不是该帖子类型的所有查询。
更新时间:
代码的结构应如下所示:
if ( get_query_var(\'paged\') )
$paged = get_query_var(\'paged\');
elseif ( get_query_var(\'page\') )
$paged = get_query_var(\'page\');
else
$paged = 1;
query_posts(array(\'post_type\' => \'video\', \'posts_per_page\' => \'3\', \'paged\' => $paged ));
while( have_posts() ) : the_post();
//MAIN LOOP...
endwhile; wp_reset_query();
next_posts_link(); previous_posts_link();
$custom_loop = new WP_Query( array(\'post_type\' => \'video\', \'posts_per_page\' => \'-1\' ) );
while ( $custom_loop->have_posts() ) : $custom_loop->the_post();
//CUSTOM LOOP...
endwhile;
wp_reset_query();