• Resolved thisisedie

    (@thisisedie)


    I’ve used this code before and it worked fine but for some reason when I drop this in the functions.php it no longer works. Has something changed in the new version of WP that’s preventing it from working? I’m using no plugins and it doesn’t work with the Twentyten theme either. Thanks :o)

    function exclude_category($query) {
    if ($query->is_home || $query->is_archive || $query->is_search || $query->is_feed) {
    $query->set('cat', '-12');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');

    Nevermind. Found the answer near the end of the comments here.

  • The topic ‘Exclude Category’ is closed to new replies.