Title: Exclude Categories
Last modified: August 19, 2016

---

# Exclude Categories

 *  Resolved [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/)
 * I have this Most Recent Posts part in my template.
    Now i need to exclude some
   categorys in this part, but i dont know how to do it.
 * The part that controlls this looks like this,
 *     ```
       <div style="float:left;width:463px;">
       				<h2 class="img_title h2"><span><?php echo OnePanelLanguage::GetText( 'most_recent' ); ?></span></h2>
       				<ul>
       					<?php while (have_posts()) : the_post(); ?>
       ```
   
 * I have tryed to use this before “while” query_posts(‘cat=-7’); that works, but
   the problems is that i have chosen to show 4 posts, and then when clicking to
   get to the next page of posts then the same posts appear.
 * So does anyone know how to fix this?
 * Thanks

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

1 [2](https://wordpress.org/support/topic/exclude-categorys/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-categorys/page/2/?output_format=md)

 *  [Mike Toppa](https://wordpress.org/support/users/toppa/)
 * (@toppa)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052379)
 * Try this with query_posts:
 *     ```
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=-7&amp;paged=$paged");
       ```
   
 * This is a poorly documented part of wordpress – you need to pass a variable to
   control the paging, or you get stuck on page 1.
 *  [Mike Toppa](https://wordpress.org/support/users/toppa/)
 * (@toppa)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052380)
 * That should be a regular ampersand in there – the forum editor converted it into
   an entity
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052395)
 * > That should be a regular ampersand in there – the forum editor converted it
   > into an entity
 * I am not sure i follow you here?
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052402)
 * I tryed the code you provided here and still getting the same result.
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052477)
 * Does anyone know how to fix this issue and get the code to work?
 *  [Chris_K](https://wordpress.org/support/users/handysolo/)
 * (@handysolo)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052479)
 *     ```
       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=-7&amp;paged=$paged");
       ```
   
 * see the `&amp;` in the second line? Change that to a normal ampersand (&) — this
   forum’s code editor is translating it for some odd reason.
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052503)
 * Yes i have done that but it does not work anyway with the pagnation or what it
   is called.
 * I still get the same posts on every page.
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052630)
 * Why are you deleting my post all the time?
 * If no one can help me here, does anyone know where to turn with this issue?
 *  [Mike Toppa](https://wordpress.org/support/users/toppa/)
 * (@toppa)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052632)
 * Hi Granit – the code I posted was just a snippet to address what sounded like
   the key problem. Can you show me how you incorporated my code into yours?
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052634)
 * I have done like this, i am not that good when it comes to this and put the code
   where i tough it should be.
 *     ```
       <div style="float:left;width:463px;">
       				<h2 class="img_title h2"><span><?php echo OnePanelLanguage::GetText( 'most_recent' ); ?></span></h2>
       				<ul>
       					<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       query_posts("cat=-7&amp;;paged=$paged"); while (have_posts()) : the_post(); ?>
       ```
   
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052643)
 * toppa, if you need to see the while file please let me know because i really 
   don´t follow you regarding this code you presented.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052645)
 * If necessary, post the whole template (all the code) in a pastebin and report
   the link back here.
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052646)
 * Here the file is, i don´t know if there are any needs for the other files since
   to my knowledge it is in this file this is controlled.
 * [http://pastebin.com/m4985da9f](http://pastebin.com/m4985da9f)
 *  Thread Starter [Granit](https://wordpress.org/support/users/granit/)
 * (@granit)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052664)
 * Sorry for all of my post, but this is really frustration that no one can help
   out on this. I really tough that there would be some expertise here that would
   know a little bit of wordpress code.
 * And since i don´t have any place to turn to this was my last option.
 * I would be very glade is someone could point me in the direction of a place where
   one could get some support on this mater.
 * And i hope that the moderator don´t delete my post.
 *  [Mike Toppa](https://wordpress.org/support/users/toppa/)
 * (@toppa)
 * [17 years ago](https://wordpress.org/support/topic/exclude-categorys/#post-1052665)
 * Your pastebin code looks mostly fine to me – you’ve correctly put the query_posts
   call before the Loop. I think it’s just a small typo causing the problem – you’ve
   got an extra semicolon after the ampersand (right before paged=$paged). Sorry,
   I would simply put the correct line here, but the forum editor would just muck
   with my ampersand again.
 * Also, I’d recommend less agitation in how you’re phrasing your requests here.
   Most folks in the forums (like me) aren’t getting paid to be here. I’ve actually
   just recently begun helping out. It’s one thing to get agitated if you’re paying
   for support; it’s another when people are here making a community effort.

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

1 [2](https://wordpress.org/support/topic/exclude-categorys/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/exclude-categorys/page/2/?output_format=md)

The topic ‘Exclude Categories’ is closed to new replies.

 * 17 replies
 * 4 participants
 * Last reply from: [Granit](https://wordpress.org/support/users/granit/)
 * Last activity: [17 years ago](https://wordpress.org/support/topic/exclude-categorys/page/2/#post-1052670)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
