Show Current Logged In Users Posts With Pagination!


I've created a query that shows a users posts:

<?php get_currentuserinfo(); query_posts(array('author'=>$current_user->ID)); ?>
(I put it in front op the loop <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>:wink:.

Combined with a pagination plugin called: wp pagenavi.

But the wp-pagenavi doesn't work because it's not connected to the query ofcourse... =(

Would someone know how to fix this?



  • Philip John
    • DEV MAN’s Apprentice

    Hi J!

    Sorry we didn't respond sooner!

    I believe the best way for you to achieve this is actually to create a second loop in your page, rather than the code you have above.

    To do this, you can copy the existing loop but place WP_Query() in front of that, passing the right arguments to limit it to each user and enable pagination.

    Then you'll need to place WP_Reset_Query() before your second loop to make WP forget those arguments and run through all your posts.

    That's a fairly basic summary of what you need to do - if you have trouble figuring that out, do let us know.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.