Just thought I’d share a piece of code other people might be looking for. This is how to get blog posts from multiple categories while retaining navigation (paging).
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php
query_posts( $args=array( 'category__in' => array(1,2), 'paged' => get_query_var('paged') ) );
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
get_template_part( 'content', get_post_format() );
?>
<?php
endwhile;
}
twentyeleven_content_nav( 'nav-below' );
wp_reset_query();
?> |
Get_template_part is the same as found in the loop of twentyeleven, and as you can see the function twentyeleven_content_nav works fine. Be sure it always is between endwhile and the reset query.
Note: you need to create a custom page template in order for this to work.
