0

I having trouble with the results, the url and the pagination shows correctly, but when I'm on page 2 or 3 etc... there only show the results from the first page. this is my code.

<?php $portfolioloop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 12 ) ); ?>
<?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>

Code for the loop here

<?php endwhile; // end of the loop. ?>
<?php if (function_exists('wp_pagenavi')) {
wp_pagenavi( array( 'query' => $portfolioloop ) ); } ?>

WP Page Navi - VersiĆ³n 2.74

Permalink structure - "/%postname%/"

1

you are quering the same posts over and over, and that is way you are getting the same posts, to fix it just add 'paged' => get_query_var('paged') to your query arguments, so change:

<?php $portfolioloop = new WP_Query( array( 'post_type' => 'portfolio', 'posts_per_page' => 12 ) ); ?>

into:

<?php $portfolioloop = new WP_Query( array( 'paged' => get_query_var('paged'), 'post_type' => 'portfolio', 'posts_per_page' => 12 ) ); ?>

and just to make sure you are ok and to avoid errors add wp_reset_postdata(); at the end of your code.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.