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 have a custom post type, jobs, being displayed on an external page using WP_Query() - the query itself is working fine.

However when I try to paginate the results, the older/newer links show up, but when I click on them, the content doesn't change - ie the page 'number' changes in the URL & the page reloads, but the posts don't move on.

I've tried using Wordpress' default next_posts_link & previous_posts_link and also with the wp_pagenavi plugin. In the code below I'm using wp_pagenavi .

Here's my code:

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

        $params = 
        array(  'post_type'          => 'job', 
            'post_status'        => 'publish',
            'posts_per_page'     => 3,

        $temp = $wp_query;
        $wp_query= null;
        $wp_query = new WP_Query();

        $wp_query->query($params); ?>

  <?php if (function_exists('wp_pagenavi')){ wp_pagenavi(); } ?>

  <?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

// doing things with the post

 <?php endwhile; endif ?>
 <?php $wp_query = null; $wp_query = $temp; wp_reset_query() ?>

Any help would be greatly appreciated it - this is driving me up the wall! ^_^

share|improve this question
How many posts do you have in total? – Rob Vermeer Jan 9 '12 at 22:27
10 - I wish it was that simple ^_^ – user11860 Jan 9 '12 at 22:28

A problem with a custom query is that the posts_per_page resets before the page loads. So if you got 10 posts, than you only have one page, because the default posts_per_page is 10. If you have 11 posts than you will see the second page, but not beyond that.

Solution for this is changing your posts_per_page settings in the back-end: Settings > Reading > Blog pages show at most > 3. But this will change all archive page settings. Quick fix for this is adding

<?php global $query_string; query_posts($query_string . '&posts_per_page=10'); ?>

at the top of your archive templates where you want the default posts_per_page.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.