Title: Exclude Categorys from posts loop
Last modified: August 19, 2016

---

# Exclude Categorys from posts loop

 *  [Randy](https://wordpress.org/support/users/randylee/)
 * (@randylee)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/exclude-categorys-from-posts-loop/)
 * I have multiple categories and i want to exclude 2 of them. My problem comes 
   when I go to the next page of posts. All of the following lines will exclude 
   the categories but only on the first page of post results.
 * when i use the following line my ‘next page’ link go no where, it goes to the
   same page i click from.
 * <?php query_posts(‘cat=-17,-36’); ?>
 * when i use the following line my ‘next page’ link go no where, it goes to the
   same page i click from. using home.php
 * <?php if ( is_home() ) {query_posts(‘cat=-17,-36’); } ?>
 * when i use the following line my ‘next page’ link goes to the next page but the
   categories are not excluded.
 * <?php if ( is_home() && !is_paged() ) { query_posts(‘cat=-17,-36’); } ?>
 * im looking to exclude these categories through out my regular posting not just
   on the first page.
 * Im putting these lines right before the loop. like this
 * <?php if ( is_home() && !is_paged() ) {query_posts(‘cat=-17,-36’); } ?>
    <?php
   if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
 * ??? anyone…

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

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/exclude-categorys-from-posts-loop/#post-687265)
 * See:
 * [http://wordpress.org/support/topic/57912#post-312858](http://wordpress.org/support/topic/57912#post-312858)
 *  Thread Starter [Randy](https://wordpress.org/support/users/randylee/)
 * (@randylee)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/exclude-categorys-from-posts-loop/#post-687303)
 * thanks alot that was it. infact I think ive seen that topic page before but i
   just didnt understand it. must have been one of those late nights.
 *  [rodsherwin](https://wordpress.org/support/users/rodsherwin/)
 * (@rodsherwin)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/exclude-categorys-from-posts-loop/#post-687589)
 * Any ideas why the work around suggested by Kafkaesqui is broken in 2.6.1?

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

The topic ‘Exclude Categorys from posts loop’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [rodsherwin](https://wordpress.org/support/users/rodsherwin/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/exclude-categorys-from-posts-loop/#post-687589)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
