There are a few other questions about this (and WP_Query pagination seems to be a huge question for a lot of people) so I’m trying to narrow down exactly how to make it function.
I’m able to create a single custom loop with pagination this code:
// http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$args = array(
'showposts' => 2,
'paged' => $paged
);
$wp_query->query($args);
while ($wp_query->have_posts()) : $wp_query->the_post();
// The Post
the_title();
echo '<br>';
the_category(' ');
the_excerpt();
echo '<hr>';
endwhile;
// http://codex.wordpress.org/Function_Reference/paginate_links#Examples
$big = 999999999;
$pag_args = array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
);
echo paginate_links($pag_args);
$wp_query = null;
$wp_query = $temp;
…but naturally if I copy/paste this loop, it works as an exact clone, meaning, when you click on “Page 2” it takes you to Page 2 for BOTH the loops.
Is there a way to break these apart from each other so each paginates separately?
Here’s the full code complete with duplicate loop if anyone is interested in setting up their own local version and toying with it: http://paste.pocoo.org/show/573108/
Yes, it can be done. The key is to make the
format
parameter different for the two queries: