Title: exclude category
Last modified: August 21, 2016

---

# exclude category

 *  Resolved [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-22/)
 * Can i Exclude one category from the front page? How to do it?

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

 *  [Sampression](https://wordpress.org/support/users/sampression/)
 * (@sampression)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4544905)
 * Hi Jurgiel,
 * Please replace following code in header.php file
 * `$args = array();`
 * by
 *     ```
       $args = array(
         'exclude' => array(category_id )
       );
       ```
   
 * Here category_id refers to the id of the category that you want to exclude in
   front page. More than one category can be excluded by adding category id separated
   by a comma like category_id1, category_id2. For further details you can also 
   refer to [http://codex.wordpress.org/Function_Reference/get_categories](http://codex.wordpress.org/Function_Reference/get_categories).
 * And also please find $categories = get_categories(); and delete it from header.
   php
 * Thank You
 *  Thread Starter [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545105)
 * oh no! Thank You. Works perfectly 🙂
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545127)
 * Bonjour!
    I have excluded some categories like jurgiel did and this works nice.
   But when “show all” is selected again, all categories are shown. Where can I 
   change this? Thanks a lot.
 * The Test Site:
    [http://www.wp.pep-berlin.de/wp/](http://www.wp.pep-berlin.de/wp/)
 * The code:
 *     ```
       <ul class="nav-listing clearfix">
   
               <li><a href="#" data-filter="*" class="selected"><span></span><?php _e('Show All','sampression'); ?></a></li>
              <?php
       		/*to exclude some categories */
       		$args = array(
       		'exclude'=>  array(8,9,10,11,12)
       		);
       		$categories = get_categories($args);
               foreach($categories as $category):
               ?>
               <li><a href="javascript:void(0);" data-filter=".<?php echo $category->slug; ?>" id="<?php echo $category->slug; ?>" class="filter-data"><span></span><?php echo $category->name; ?></a></li>
               <?php
               endforeach;
               ?>
           </ul>
       ```
   
 *  Thread Starter [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545131)
 * that’s strange. But today i posted news on excluded category and it showed up
   in the main page. I checked and everything seams to be all right.
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545132)
 * Hello jurgiel,
    would you send me teh URL you are talking about? Maybe it can
   help me. Thank you.
 *  Thread Starter [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545133)
 * zabawy.zielonagrupa.pl
 * The excluded category is “Aktualnosci” but the first post – with the photo is
   from this category.
 * Thanks a lot
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545134)
 * Hello
 * the other post from your category-1, “Ruszamy”, ist also schown on the home page.
   So it seems like your “exclude” does not work.
    I think we don’t habe exacttlx
   the same problem: my “exclude” works by loading of the home-page but not any 
   more when you choose “show all” once more.
 * Have you wrote
 *     ```
       $args = array(
         'exclude' => array(1)
       );
       ```
   
 * ?
 *  Thread Starter [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545135)
 * hmmm thats true. The category isn’t shown, but the post are.
    You see – the ‘
   Aktualnosci’ category is excluded in the menu – but the post are visible.
 * Anybody know how to change it?
 * EDIT: yes i wroted
 *     ```
       $args = array(
         'exclude' => array(1 )
       ```
   
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545136)
 * Her is how “my” script for the entire list would look like in your case:
 *     ```
       <ul class="nav-listing clearfix">
   
               <li><a href="#" data-filter="*" class="selected"><span></span><?php _e('Show All','sampression'); ?></a></li>
              <?php
   
       		$args = array(
       		'exclude'=>  array(1)
       		);
       		$categories = get_categories($args);
               foreach($categories as $category):
               ?>
               <li><a href="javascript:void(0);" data-filter=".<?php echo $category->slug; ?>" id="<?php echo $category->slug; ?>" class="filter-data"><span></span><?php echo $category->name; ?></a></li>
               <?php
               endforeach;
               ?>
           </ul>
       ```
   
 *  Thread Starter [jurgiel](https://wordpress.org/support/users/jurgiel/)
 * (@jurgiel)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545137)
 * Thats exacly what i have. And still, the category is excluded, but it posts are
   one the main page
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545139)
 * Well, I hope the author can soon help us…
 *  [Sampression](https://wordpress.org/support/users/sampression/)
 * (@sampression)
 * [12 years ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545174)
 * The above code removes the category from the filter menu only, if you do not 
   want the post from the particular category on the posts as well you have to add‘
   category__not_in’ => array(category_ids) argument in the query that is in the
   index.php file.
 * Please find
 *     ```
       query_posts( array(
       		'post__not_in' => get_option( 'sticky_posts' ),
       		'paged' => $paged
       		) );
       ```
   
 * in the index.php file and replace it by
 *     ```
       query_posts( array(
       		'post__not_in' => get_option( 'sticky_posts' ),
                       'category__not_in' => array(category ids separated by comma),
       		'paged' => $paged
       		) );
       ```
   
 * Hope this is what you are looking for.
 *  [Bocq](https://wordpress.org/support/users/bocq/)
 * (@bocq)
 * [12 years ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545175)
 * Thanks a lot.

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

The topic ‘exclude category’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/sampression-lite/2.3/screenshot.
   png)
 * Sampression Lite
 * [Support Threads](https://wordpress.org/support/theme/sampression-lite/)
 * [Active Topics](https://wordpress.org/support/theme/sampression-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/sampression-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/sampression-lite/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [Bocq](https://wordpress.org/support/users/bocq/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/exclude-category-22/#post-4545175)
 * Status: resolved