这是我的工作分页查询。我已将其更新为使用您问题中的参数:
<?php
if ( get_query_var(\'paged\') ) {
$paged = get_query_var(\'paged\');
} else if ( get_query_var(\'page\') ) {
$paged = get_query_var(\'page\');
} else {
$paged = 1;
}
$args = array(
\'post_type\' => array(\'post\', \'music\', \'videos\'),
\'post_status\' => \'publish\',
\'posts_per_page\' => 10,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'paged\' => $paged
);
// Create new query
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query( $args );
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<!-- add your content -->
<?php
// End the custom loop
endwhile; ?>
<?php
// This is where I put my pagination, included from another file
echo get_template_part( \'pagination\' ); ?>
<?php
// Need this to reset the query
$wp_query = null;
$wp_query = $temp; // Reset
?>
我看到您使用的是编号分页,而我使用的是默认的wordpress next和previous分页。我认为对任何一种类型使用此代码都不会有问题。