Forums

Exclude category from archives (6 posts)

  1. stevenoi
    Member
    Posted 3 years ago #

    Hi, I made a wordpress site with a blog template and a portfolio template. They are seperated by excluding the portfolio category from everything, but only I don't know how to exclude a category from the archives. So if I view : http://www.domain.com/2009/05, I won't see posts from category 1.

    - Steven

  2. MichaelH
    Member
    Posted 3 years ago #

    With the help of the Template Hierarchy article, determine what Template is displaying your date archives then add code to 'exclude' the category in that template.

    Might also consider a plugin such as Custom Query String Reloaded. I also think Advanced Category Excluder might work.

    Related:
    query_posts()
    Stepping Into Template Tags
    Stepping Into Templates

  3. stevenoi
    Member
    Posted 3 years ago #

    Thanks, but so far it didn't worked. I made a file ( date.php ) and insert a code to exclude the category with ID 1, so paste this :
    <?php query_posts('cat=-1'); ?>
    But then wordpress will show just all post that aren't in cat 1...

  4. stevenoi
    Member
    Posted 3 years ago #

    Sorry, but is it possible to do this without a plugin?

  5. stevenoi
    Member
    Posted 3 years ago #

    Ah, found the solution !

    <?php
    $wp_query->query_vars["cat"] = -1;
    $wp_query->query_vars["posts_per_page"] = 16;
    $wp_query->get_posts();
    ?>

    Wil exclude all post from cat 1.

    But 1 last question. If I use the archives, or calendar widget, it will display dates when I published something for cat 1. Is it also possible to exclude that kind of things?

  6. MichaelH
    Member
    Posted 3 years ago #

    You'd have to find plugins that offer the ability to exclude categories from archive and calendar type widgets.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.