Title: Exclude category from loop when static posts page set
Last modified: August 20, 2016

---

# Exclude category from loop when static posts page set

 *  [leclerk](https://wordpress.org/support/users/leclerk/)
 * (@leclerk)
 * [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-when-static-posts-page-set/)
 * I am trying to exclude all posts from category 8 from my list of posts on a static
   posts page. This sites ‘blog’ page will not be the home page. I’m using WP as
   a CMS for this site – so have set up the Front page to display a static page 
   for Front page and Posts page under settings/reading. The static page that displays
   my posts is set up in ‘Pages’ with the title ‘News’, content is blank and it 
   is set to use the default template (I understand this will use index.php template).
   Thus the static posts page titled ‘News’ will use the main loop code included
   on the index.php template to display my blogroll. To exclude posts from category
   8 – I have added ‘<?php query_posts($query_string . ‘&cat=-8′); ?>’ before ‘<?
   php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>’ . Thus all
   posts from all categories should appear EXCEPT those from category ‘8’. Unfortunately
   ALL posts are displaying. Note it does exclude category 8 if ‘Front page’ is 
   set to ‘Your latest posts’. Is there different code when using a static page?
   many thanks.

The topic ‘Exclude category from loop when static posts page set’ is closed to new
replies.

## Tags

 * [exclude category](https://wordpress.org/support/topic-tag/exclude-category/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [static posts page](https://wordpress.org/support/topic-tag/static-posts-page/)

 * 0 replies
 * 1 participant
 * Last reply from: [leclerk](https://wordpress.org/support/users/leclerk/)
 * Last activity: [14 years, 3 months ago](https://wordpress.org/support/topic/exclude-category-from-loop-when-static-posts-page-set/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
