Support » Themes and Templates » Toolbox » [Resolved] Exclude Categories from index

[Resolved] Exclude Categories from index

  • 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)
  • Moderator Kathryn


    Automattic Happiness Engineer

    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.

    Thank you!!!

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