Home / Blog / Query_posts() with WP-PageNavi

Query_posts() with WP-PageNavi

For WordPress theme designers who use WP-PageNavi plugin and query_posts() together, it is likely that the page numbers do not show posts correctly. All pages display the same posts no matter which page you are on. Here is how to use query_posts() correctly with WP-PageNavi:

Open the file with the query_posts() function, index.php for example.

Find:

query_posts('category_name=resources');

Replace with:

query_posts('category_name=resources'.'&paged='.get_query_var('paged'));

Learn how to use query_posts().

Tags: ,

  • http://onetarek.com oneTarek

    This Site http://zced.com is using query_post() to exclude all posts in a specific tag from home page

  • http://mwdmedia-group.co.uk/ Miles

    Thanks… Great help.. Was racking my brains as it was sticking on page 1 posts even though i was clicking 3 & 4

  • http://www.pilnaskadras.lt Rimvydas

    Super! It is exactly the thing what i was looking for. Thank you very much!

  • http://www.picdesi.com Punkz

    I use query post to include posts from 5 categories shown in single category page.
    code : query_posts(‘cat=14,15,16,17,42′ . ‘&paged=’ . get_query_var(‘paged’));

    it shows pages upto 35 in pagination but pages 9 works when i click on 10th & onwards it gives Not Found Error page. what is wrong !!!