Support » Fixing WordPress » Exclude category from archives navigation

  • Resolved Christine Rondeau


    Volunteer Forum Moderator

    I have two posts categories in my site, news and jobs.

    On my side bar, I want to display the following navigation:

    I’ve been using the following:

    <li><a href="">NEWSROOM</a>
    		<?php wp_get_archives('type=yearly'); ?>

    This works, but when I click on the link to the 2008 archives, the jobs posts also appear. Is there a way to get_archives from only one category?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Eric Amundson


    Volunteer Moderator

    Check this:

    I know there’s a way to do it using php, but this may make it easier.

    Christine Rondeau


    Volunteer Forum Moderator

    Thanks sewmyheadon, I looked at the plugin, but that plugin wasn’t compatible with the option to show by year.

    Instead what I did in my archive.php file is add a simple if statement to omit the posts from the jobs category, since these will never be archived.

    <?php while (have_posts()) : the_post(); ?>
      	<?php if (!in_category(3)) { ?>
        <h5><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> &nbsp; <?php the_time('F j, Y'); ?></h5>
        <?php } ?>
      <?php endwhile; else: ?>

    And that works perfectly!

    Eric Amundson


    Volunteer Moderator

    Glad you got it working!

    Hey guys,

    Where do you put that code? I’m trying to exclude a category form the “Archive” widget, yet I cannotmake it to work. I really don’t know where to drop that code within the archive.php.

    Could you let me know where exactly?



    Find the ‘while’ loop in the archive.php page and replace it with the above code. However, remove the ‘else:’ right after the ‘endwhile;’

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude category from archives navigation’ is closed to new replies.