Support » Plugins and Hacks » Exclude Categories from Archives

  • I’m trying to exclude a few categories from my archives. I’m using Kubrick’s Archive for a template and need to finish it off so that it will exclude a few categories that I’m using to post quotes of the day and such like that.

    The page is at http://www.Suncoach.com and you can get to the Archives through the Blog. To be honest, I would like it if only the blog showed up in the Archives, I just don’t know how to do this.

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    Forum Moderator

    Try editing archive.php and adding:

    <?php query_posts('cat=-1,-2,-3');?>

    just before The Loop (if ( have_posts() ) : while ( have_posts() ) : the_post();).

    http://codex.wordpress.org/Template_Tags/query_posts

    ahh, I saw this but didn’t know where to put it. Thanks Esmi

    this isn’t working for me any ideas.

    no categories show up?

    <?php is_tag(); ?>
    
    	<?php query_posts('cat=-3');?>
    
    	<?php if (have_posts()) : ?>
    
    		<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    		<?php /* If this is a category archive */ if (is_category()) { ?>
    		 <h2 class="archive">Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
    		<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    		 <h2 class="archive">Posts Tagged ‘<?php single_tag_title(); ?>’</h2>
    		<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    		 <h2 class="archive">Archive for <?php the_time('F jS, Y'); ?></h2>
    		<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    		 <h2 class="archive">Archive for <?php the_time('F, Y'); ?></h2>
    		<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    		 <h2 class="archive">Archive for <?php the_time('Y'); ?></h2>
    		<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    		 <h2 class="archive">Author Archive</h2>
    		<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    		 <h2 class="archive">Blog Archives</h2>
    		<?php } ?>
    
    	<?php while (have_posts()) : the_post(); ?>

    I also tried this?

    <?php query_posts($query_string . '&cat=-2'); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude Categories from Archives’ is closed to new replies.