WordPress.org

Ready to get started?Download WordPress

Forums

Hide all posts in a category from the Archives (2 posts)

  1. viitoria
    Member
    Posted 9 years ago #

    I'm wondering - is it possible to keep a single (or maybe more) category's post items from showing up when the archives are called? I've tried Category Visibility, but that just destroys my permalinks and doesn't seem to really work on the archives.

    I'm using Semiologic Opt-in-Front plugin to get my updates and only my updates to appear on the front page, but they still show up in my archives when anything date-related is called. I'd like to make it so that the updates are kept from the archives all together, unless I specify for them to be called (IE, an updates archive - which I've accomplished already).

  2. Kafkaesqui

    Posted 9 years ago #

    If you're using the default permalinks, insert this just above The Loop in archive.php:

    <?php
    if(is_archive()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-10&posts_per_page=$posts_per_page&paged=$paged&m=$m");
    }
    ?>

    Using a custom permalink structure, go with this brick of code:

    <?php
    if(is_archive()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    if($year) $archivearg = "&year=$year";
    if($monthnum) $archivearg .= "&monthnum=$monthnum";
    if($day) $archivearg .= "&day=$day";
    query_posts("cat=-10&posts_per_page=$posts_per_page&paged=$paged" . $archivearg);
    }
    ?>

    In either case, change cat=-10 to cat=-[excluded_cat_id]

Topic Closed

This topic has been closed to new replies.

About this Topic