Title: Query_posts page navigation problem (3.2.1)
Last modified: August 20, 2016

---

# Query_posts page navigation problem (3.2.1)

 *  [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/)
 * Hi everyone,
 * Well, it seems that this is a common problem with **query_posts** (i’ve seen 
   many threads on Google, but none of them solved my problem).
 * I’ve added a line in my index.php page :
    `<?php $paged = (get_query_var('page'))?
   get_query_var('page') : 1; ?>` the problem is half solved, i can get to my older
   posts, but this time i have all my posts on the same page(no navigation anymore).
   here is the link : [http://blog.himstudio.com/?cat=4](http://blog.himstudio.com/?cat=4)
 * Can anyone help men on this, i’m new at WordPress (used to work with Joomla).
   
   Thanks.

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435273)
 * I think you are halfway there… you assign the proper stuff to $paged
 * Do you now include the $paged variable into your query posts?
 * (also, page should be paged, and I think your parenthesis might be wacky — I 
   believe you use ‘page’ on page templates, else ‘paged’)
 *     ```
       <?php
       $paged = ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 );
        query_posts( array(
             'posts_per_page' => 5,
             'cat' => '10',
             'paged' => $paged
        ));
       ?>
       ```
   
 * or simply
 *     ```
       <?php query_posts( array(
             'posts_per_page' => 5,
             'cat' => '10',
             'paged' => ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ),
        ));
       ?>
       ```
   
 * [http://vudu.me/10f](http://vudu.me/10f)
    My little writeup about using it
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435278)
 * I’m kinda confused ! here is my index.php can you take a look at it please? Something
   might be wrong on it 🙁
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435284)
 * [http://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html](http://scribu.net/wordpress/wp-pagenavi/right-way-to-use-query_posts.html)
 * The codex for query posts links here
 * (Queries aren’t my strength), but reading that article, all I can suggest is 
   to change both ‘page’ to ‘paged’
 *     ```
       <?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; ?>
       ```
   
 * In that line, as your file is an index, and not a page
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435445)
 * >  all I can suggest is to change both ‘page’ to ‘paged’
   >  <?php $paged = (get_query_var(‘
   > page’)) ? get_query_var(‘page’) : 1; ?> In that line, as your file is an index,
   > and not a page
 * I’ve tried this, but i got back to where i’ve started. When i try to get the 
   second page i get the error message that says that the page is not found…
    i 
   don’t get it !
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435448)
 * You can give your permalinks a reset by going to the settings->permalinks page
   and hitting save. Worth a try! That has often cleared up 404 errors for me
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435449)
 * the line
    `<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1;?
   >` shows at least all the articles.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435451)
 * right, but it doesn’t paginate
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435452)
 * many proposed solutions talk about an array..in my index file i don’t see any
   array ! could this be the source of the problem ?
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435453)
 * if you’d like, throw your code back up into a pastebin and report the link here.
   Maybe someone else can take a better look than me.
 * The array really does the same thing as the way your code is written
 * It’s cleaner, and easier to look at. Your code should provide the same functionality.
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435454)
 * indeed, i added an array to my code…it does the same thing and the problem is
   still the same.. thank you Rev.Voodoo for your help 😉
 *  Thread Starter [himstudio](https://wordpress.org/support/users/himstudio/)
 * (@himstudio)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435455)
 * this is my index file [index.php](http://pastebin.com/sde7UcSt)

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Query_posts page navigation problem (3.2.1)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 2 participants
 * Last reply from: [himstudio](https://wordpress.org/support/users/himstudio/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/query_posts-page-navigation-problem-321/#post-2435455)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
