WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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%/"

share|improve this question
up vote 1 down vote accepted

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 ) ); ?>


<?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.

share|improve this answer
Thank you!! I really apreciate this :D – Omegakenshin May 30 '11 at 16:21

protected by toscho Jun 12 '12 at 19:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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