WordPress – Exclude Posts From Certain Categories On Home Page

Posted on in For Geeks Only

If you want to exclude posts from certain categories you can add the following to your index.php page for the given theme that you are using.

Before the block of code that checks for posts with have_posts just add the following:

This line of code, along with the surrounding code is:


To determine the category ID’s you can log into the WordPress administration area and look at the links for the category ID’s. The – in front of the category ID’s above specifies that those category id’s won’t be shown.

Leave a Reply

What our clients are saying

I want to thank you for your help with our website development project. Your programming skills, attention to detail, and ability to interact directly with our client were excellent. You have provided tremendous value to my organization. With a project of this magnitude, including the use of web services to push data out to 19 sub-websites, your ability to overcome our unique challenges and coordinate with my IT team was exceptional. I appreciate your help, and I am certain that your expertise was key to the project's success. Thanks again, I look forward to working with you on our next endeavor!

~ John Forgione – Executive Vice President – SFA Marketing, Inc.

Read More