Hide Category Posts on WordPress Homepage
Tue, May 12, 2009

If you’ve been reading my blog you notice I use twitter tools to aggregate my weekly tweets. I do this for two reasons. 1) Automatically generated content keeps the blog search engine fresh, and 2) I post a lot of tips and links that I want to archive. The issue is these posts overwhelm the deeper, possibly more valuable, posts on the homepage. This morning I set out to find a good way to block the ‘twitter’ category from displaying on the homepage.
Like many other questions about WordPress, a simple Google search will return the solution you need. This one wasn’t any different and my search ‘hide category on WordPress homepage’ eventually led me to the right answer. My issue is all the different ways people are doing it. While they all work (I’m assuming) I’d rather go with the cleanest and most recommended code available. This came from WP’s Codex documentation.
Here is the code to hide categories on your WordPress blog homepage:
Place this code in your index.php file:
<?php
if (is_home()) {
query_posts(”cat=-3″);
}
?>
Your homepage will display posts from all categories except category ID 3
Note: In some versions this code will need to be placed in the home.php! Also, in some themes you will have to dig deeper to find existing query parameters. Let me know if you have questions.
If you’re looking to block more than one category, use this code:
<?php
if (is_home()) {
query_posts(”cat=-1,-2,-3″);
}
?>
Tested with WP 2.1.2
Please comment on your success or failure with this update. Be sure to note WP version and any theme you have active. Feel free to add a link to your blog as well!







I got to this site while looking for imfo to improve my Internet marketing skills and I’m glad that I found it. You are providing good quality all-round info that will be very usefull to anyone in this field. What does a slum dog have to do with making money online? You’d be surprised
Thank you for post. It’s really imformative read.
This code doesn’t work for me, I’m using the latest version of Wordpress (2.8.2) and all it does is:
a. it DOES eliminate the category from the home page
b. it also repeats the same entries across all pages i.e. when I click to see previous entries, I get the same ones from the first page.
Hmmm, great idea. Kind of an archive for your tweets. Forwarding your tweets to your blog, it never occured to me.
Thanks for the heads up!
Iniara, I’ll look into that issue
Daan it’s great if you have categories you don’t want overwhelming the homepage. For this blog i use a plugin to archive my tweets. These posts don’t need to be on the homepage!
Exactly, it’s a great idea.
What is the plugin called?
The plug-in is called Twitter Tools
Hey, I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say GREAT blog!…..I”ll be checking in on a regularly now….Keep up the good work!
- Marc Shaw
Hi, Thank you for the great quality of your blog, each time i come here, i’m amazed.
This is my first time here and this post was indeed thought provoking. I find there is a gap between the no. of readers and the comments . I personally think that even though I ask questions not many come fwd to answer. And believe you me, my questions are not ‘Big Bang theory’ types.