[resolved] Exclude Categories from index (3 posts)

  1. Sherry
    Posted 2 years ago #

    I am stumped on how to exclude categories from the index.php page using the excerpt tag. I used to be able to do it, but can't find it in your theme.

  2. Hi Sherry, there are a few different ways to exclude categories from the blog homepage, but a simple one that works in any theme, with both excerpts or full posts, is described here:


    It's the section called "Code to Exclude Category Posts in WordPress" and it's a function that looks like this:

    function exclude_category($query) {
    if ( $query->is_home() ) {
    $query->set('cat', '-xx');
    return $query;
    add_filter('pre_get_posts', 'exclude_category');

    You'd replace xx with the category ID you want to exclude.

    Let me know if this does the trick.

  3. Sherry
    Posted 2 years ago #

    Thank you!!!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic