Title: Query posts and Pagination Links Broken
Last modified: August 19, 2016

---

# Query posts and Pagination Links Broken

 *  [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/)
 * Ive searched around for an answer to this and saw a couple of the same posts 
   around with the same problem, but no actual answer unfortunately.
 * Problem being I have 3 seperare categories being displayed on 1 page… I would
   like to make it so that the Main category of the page can be scrolled through
   to older posts with pagination.
 * I put the code in after <?php endwhile ?>, the pagination displayed, and the 
   links worked, however the posts on the page remained the same and didnt change
   regardless of which page I went to.
 * After reading some older posts I have probably used ‘query_posts’ wrong, so hopefully
   somebody here can help.
 * Im using Query_Posts 3 times like so:
 *     ```
       <?php
       query_posts('category_name=news');
       while ( have_posts() ) : the_post() ?>
   
         // styling here //
   
       <?php endwhile ?>
       ```
   
 * Then that is simply repeated on the page with a different category_name.
 * Link to site: [http://www.thefightlounge.co.uk](http://www.thefightlounge.co.uk)
 * Thanks,

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/page/2/?output_format=md)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884785)
 *     ```
       <?php
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       $args= array(
       	'category_name' => 'news',
       	'paged' => $paged
       );
       query_posts($args);
       ?>
       ```
   
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884944)
 * A little more info one where to place the code would be brilliant.
 * Do I need to add this to every place ive currently used the Query_Posts?
    Or 
   just on the posts I would like to Paginate?
 * With the code above placed just on the main “News” part of the query it looks
   like this (and doesnt work still)
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884952)
 * Heres link to current code: [http://wordpress.pastebin.com/JZDiK1tX](http://wordpress.pastebin.com/JZDiK1tX)
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884979)
 * Apologies for posting 3 times. Any toher help available? Or the above code being
   explained? cheers
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884980)
 * > Problem being I have 3 seperare categories being displayed on 1 page
 * What template file is this in?
    Do you use multiple loops? Put the full full 
   content of the template file you are using in the pastebin.
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884981)
 * Pastebin Link : [http://wordpress.pastebin.com/tBisk8P2](http://wordpress.pastebin.com/tBisk8P2)
 * This is in the homepage template
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884982)
 *     ```
       $wp_query->query('cat=3&showposts=5'.'&paged='.$paged);
       ```
   
 * $paged is never defined in this query as per above…..
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884984)
 * This is with the code added from further up the page, that I think I entered 
   wrong… [http://wordpress.pastebin.com/XcPAtR9F](http://wordpress.pastebin.com/XcPAtR9F)
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884985)
 * Have you tried it with the code esmi gave you?
    Pastebin link: [http://wordpress.pastebin.com/5Rgs3udr](http://wordpress.pastebin.com/5Rgs3udr)
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884988)
 * This is the code asmi gave me: [http://wordpress.pastebin.com/XcPAtR9F](http://wordpress.pastebin.com/XcPAtR9F)
 * The code you just gave me didnt work either ([http://wordpress.pastebin.com/5Rgs3udr](http://wordpress.pastebin.com/5Rgs3udr))
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884989)
 * well, now I’m more confused…you have the query on line 17…. and then what looks
   like a loop starting at 27, but no loop opening (if have posts/while have posts…)
 * and no endwhile, so that first loop isn’t really a loop….so that may be what 
   throws that pagination
 * line 38 and 52 are both nav links, not in a loop
 * and the 63 and 81 are queries again, that do have full loop (while have posts/
   end while) but no pagination in the query…..
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884990)
 * Rev. Voodoo, Which pastebin link are you referring to? (Theres about 3 different
   ones above haha).
 * Could you please submit the edit on the pastebin too and ill test it out.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884992)
 * [http://wordpress.pastebin.com/XcPAtR9F](http://wordpress.pastebin.com/XcPAtR9F)
   
   I was referring to this one
 * Which one are you using that you are trying to get functioning correctly?
 *  Thread Starter [mikedistras](https://wordpress.org/support/users/mikedistras/)
 * (@mikedistras)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884993)
 * Im trying to get any that will get the pagination to work just on that main ‘
   News’ Category…
 * I added `while ( have_posts() ) : the_post()` after `query_posts($args);` and
   then the endwhile After the post styling, then the navigation straight after 
   endwhile.
 * Still doesnt work… Did i add them in the wrong order/wrong place?
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/#post-1884995)
 * [http://wordpress.pastebin.com/3EByJMFh](http://wordpress.pastebin.com/3EByJMFh)
   
   Something like that for the first loop….
 * Thing is I’m not sure why you have double nav, etc for the news section…. Also
   had to reset the query after that
 * Every query should have a reset after it on multiple loops…. there is definitely
   more work to be done here, just guiding a bit….

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/page/2/?output_format=md)

The topic ‘Query posts and Pagination Links Broken’ is closed to new replies.

## Tags

 * [category_name](https://wordpress.org/support/topic-tag/category_name/)
 * [navigation](https://wordpress.org/support/topic-tag/navigation/)
 * [pagination](https://wordpress.org/support/topic-tag/pagination/)
 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 19 replies
 * 5 participants
 * Last reply from: [itsbarry](https://wordpress.org/support/users/itsbarry/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/query-posts-and-pagination-links-broken/page/2/#post-1885130)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
