Okay
  Public Ticket #2542579
Hiding a category of posts in the blog
Closed

Comments

  •  2
    transparenceco started the conversation

    I want my blog page to show all post categories except the careers category which will have its own page.

    What is the cleanest way to do this in your theme?

    Thanks

  •  2
    transparenceco replied

    Never mind I added the following function and got what I wanted, thanks!

    function exclude_category_home( $query ) {
    if ( $query->is_home ) {
    $query->set( 'cat', '-5' );
    }
    return $query;
    }
     
    add_filter( 'pre_get_posts', 'exclude_category_home' );


  • [deleted] replied

    I'm happy to hear thatsmile.png

    Have a great day!