Support » Fixing WordPress » Excluding a category from monthly/daily archives

  • Resolved pauljohns


    I am in the process of making my girlfriend a web site @
    Using <?php query_posts(‘cat=-2’); ?> in my archives page, I am able to exclude category 2 (books) from my yearly archives with no problems, see

    This code however, creates another issue. On the monthly archives page (May, for example: the posts are displayed the same as if they were on the yearly archives page, with other months’ posts showing up as well. Same for daily archives page.

    Can someone tell me a better way to exclude category 2 from all of my archives page, or point me to a good plugin that does the job?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Just a guess. With the query_posts you over-ride the default Loop in the archive.php and I assume you are using (better to say: WP is using) the same template file to display any kind of archives… it will always show you tha same.

    Possible workaround:
    See the date.php and archive.php – though that might not be enough.
    You can also take a look at the deafult theme’s archive.php file to see how it uses a bunch of if_statements; maybe that will give you a start.

    That sounds like good advice, but I decided to go another route (mostly to make it easier): just use different display info for the category I was previously trying to exclude. Later, though, i might go back and change that. thanks Moshu.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Excluding a category from monthly/daily archives’ is closed to new replies.