WordPress.org

Ready to get started?Download WordPress

Forums

Exclude category from loop when static posts page set (1 post)

  1. leclerk
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic