• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

WP SITES

2296

Original Genesis Tutorials & 5000+ Code

Snippets

  • Subscribe
  • Full Access
  • Videos
  • Log in
  • Twitter
  • Facebook
  • LinkedIn
  • Email
  • More
  • Reddit
  • Tumblr
  • Google
  • Print
  • Pinterest
  • Telegram
  • Pocket
  • Skype
  • WhatsApp

How To Exclude Posts In Specific Categories From Displaying

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)

You can:

  1. Install a plugin
  2. Add a custom function to your child themes functions.php file

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.

You can change the category parameters and conditional tag to suit your needs.

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.

Related Tips

  • 3 Ways To Remove or Exclude Posts From Your Home Page Loop
Subscribe for new Genesis Tutorials

Primary Sidebar

Brad Dalton Specializes In StudioPress child theme customization & code modification. Access all code

Featured Downloads

  • Responsive Image After Header On Single Pages 67126
  • Rotate Widget Background Images In Genesis 67200
  • Template To Display All Posts by Each Category In Genesis 67050
WordPress Speed Test
  • Membership
    • Account Subscription Details
  • Tagged by Theme
  • Blog
  • T.O.C
    • Membership F.A.Q’s
  • RSS
  • Contact
  • Newsletter ( Twice Weekly )

Usage Policy · Tools & Resources


Images, code, and content on this website are property of wpsites.net and are protected by copyright law.
WP Sites does not grant permission for any repurposing, republication, or redistribution.
"Disclosure: Some of the links in some posts are "affiliate links."
This means if you click on the link and purchase the item, I will receive an affiliate commission.
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.