How to NOT display a category on your blog
Mar 8th, 2009 by Jane Blogs
Sounds weird, huh?
Why on earth would you not want to display a whole section of posts that you’ve slaved over for your adoring readership?
Usually it’s because the category complements, but is different to, your blogs’ main topic.
Such as in my slowly-emerging gardening blog, where I have chosen to keep the diary of our familys’ gardening efforts separate from the majority of companion / organic gardening posts.
The diary is interesting in the context of a gardening blog, but not the sort of thing to really grab a new reader. Anyone who’s interested in my own experience with gardening with children will usually click on the link of their own accord, and it adds a nice personal touch that I choose to share it with people.
Structuring a blog like this adds depth and interest. There’s more to see than just the most recent few posts, and you can cover a variety of semi-related topics that may interest your readers.
So if you have content that doesn’t quite fit into the regular stream of your blog, here’s how to exclude that category, so that it will look like a sub-blog.
1. Open index.php
remember to back-up first!
2. Look for this line of code:
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
This is the first line of The Loop, the most important piece of code in a WordPress blog.
It’s what (literally) makes the world go ’round, cycling through the posts to display until it’s told to stop.
3. Find the number ID of your category
You’ll need to know this number so that you can tell wordpress which category you want excluded.
Go to ‘Categories’ and ‘Edit’ that particular category. The url of the edit page for the category will be something like;
http://heart-this.com/wp-admin/categories.php?action=edit&cat_ID=20
Where 20 is the number of the category that I was editing. Your number will obviously be different.
4. Insert this code directly below:
<?php if (in_category(‘category number‘) && is_home() ) continue; ?>
Category number is the number of the category that wordpress had assigned at the time you created the category.
4. Save index.php
5. Link to it
A special link in your sidebar to draw attention to your extra content will be needed now.
Try using a graphic to make it stand out as a special link to your “bonus” category.
It’s no good writing all that extra content it if you’re not going to show people where to find it!
Related posts:







