WordPress.org

Support

Support » How-To and Troubleshooting » How to exclude categories from the archives list?

How to exclude categories from the archives list?

  • I have several categories of posts that don’t belong in the blog…they’re used for other purposes. I’ve excluded those categories from the blog posts, but they still show up in the archives…or rather, they still create a listing in the archives list.

    I’ve tried this in the functions file…

    function exclude_category($query) {
    if ( $query->is_archive ) {
    $query->set('cat', '-3 -4 -5');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');

    …but it doesn’t work. Now, the months of the excluded posts continue to show up in the list, but clicking them takes you to a 404 page. How do I exclude them entirely?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to exclude categories from the archives list?’ is closed to new replies.