There’s different ways you can exclude all posts in one or more categories from displaying on your home and/or blog pages.
We’ll be using pre_get_posts
pre_get_posts should be used in custom functions. (child themes)
- Install a plugin
- Add a custom function to your child themes functions.php file
Demo Video #
Shows all posts in category 9 which is the lifestyle category, removed from the front page loop.
Add Code To Themes Template Files
You could also add the above code to any theme which uses an index file like one of the default WordPress themes. Preferably not in the parent theme.
Another option would be to add this code into your home.php file within the loop.
pre_get_posts & Category_Parameters Function
Use this code in your child themes functions.php file.
This is the best method in my opinion.
Or this method :
This code works with Genesis theme framework and excludes posts from category 27 and 30 from displaying on the home page.
It wouldn’t be difficult to change the is_home conditional tag and replace with your own category i.d’s.