• Resolved Sherry

    (@dreamer0201)


    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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:

    https://www.locoed.com/web-design/how-to-exclude-category-posts-wordpress-tutorial-code/

    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.

    Thread Starter Sherry

    (@dreamer0201)

    Thank you!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude Categories from index’ is closed to new replies.