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'm working on a site that allows users to browse through pending posts/content on the front-end.

However, I can't seem to get pagination working with those posts. I've got a custom query that brings up the first page of pending posts on a category page, archive, etc.

But the Page 2, 3, etc. doesn't work.

Any thoughts?


Here's the example code I'm working with:

$args = array(
    'cat'      => $cat_ID,
    'paged' => get_query_var('paged'),
    'showposts' => 50,
    'posts_per_page' => 50,
    'post_status' => 'pending',



if( have_posts() ) : while (have_posts()) : the_post();

//Post code inserted here

<?php endwhile; ?>
<?php endif; ?>
share|improve this question
Post the code...? – Stephen Harris Jun 29 '12 at 22:30
I posted the code. This works fine if the posted is published, but for pending posts, I can't seem to find a way to get it working. – David Jun 30 '12 at 1:11
Where is this code? More specifically is there a page that users navigate to to view the pending posts? – Stephen Harris Jun 30 '12 at 10:21
This actually is a modified category page. It works fine when loading that page, but /category/page/2/ does not load. I get a 404 error page. Basically its not finding the "pending posts" in this case. If I change the posts to "published" everything works fine (that is, the published posts show up on paginated pages. Pending posts still do not show). I think that Wordpress is just setup to only deal with published posts on paginated pages. I'm trying to find a way around that. – David Jun 30 '12 at 16:43
Yup, the problem is query_posts - so the user navigates to a particular category term page - which you use to display the pending posts? I ask, because it means I know what query you want to change as it goes through pre_get_posts – Stephen Harris Jun 30 '12 at 16:55

Check this out: http://css-tricks.com/snippets/wordpress/paginate-custom-post-types/ It is meant for custom post type, but I think it would work for you too.


The important part about this link is the link was the use of the first lines before the loop:

$temp = $wp_query; 
$wp_query = null; 
$wp_query = new WP_Query(); 
$wp_query->query(here goes the query);

But I think a better solution would be to use pre_get_posts hook, I think it will solve your pagination problem, this is also the best practice.

You can use this code for your pagination:

echo paginate_links( array(
'base' => @add_query_arg('paged','%#%'), 
'format' => '',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'prev_text' => '',
'next_text' => ''

If you used the method with the WP_Query you should make sure you have this code at the end of your pagination code:

$wp_query = null; $wp_query = $temp;
share|improve this answer
You're linking to a "normal" paginated template code. Not even a good example of code: wp_query->query('showposts=6&post_type=news'.'&paged='.$paged); . Looks funny... – kaiser Jun 29 '12 at 23:48
Yea, this solution didn't work. Any other ideas? – David Jun 30 '12 at 18:10
Yes, best on your last comment "This actually is a modified category page. It works fine when loading that page, but /category/page/2/ does not load. I get a 404 error page. Basically its not finding the "pending posts" in this case..." You seems to have another problem, I thought you problem was to get the navigation working, not the pagiantion itself – ItayXD Jun 30 '12 at 18:43

Your Answer


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

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