Don’t show a particular category on blog homepage

For a long time I have this feeling that providing content to social networks is similar to give them money. I usually don’t get a thing when posting or sharing content there, at least not something different than my friends/followers noticing that.

So, I’d like to use my blog for the sharing stuff, but sometimes that thing that I’m sharing is just too dump to be in the homepage. I didn’t knew how to hide posts from the homepage in a quick way. There is a plugin that let you set where the post could be seen (like in archives, search and stuff like that), but is not what I’m looking for, I want something simple.

So, there is another way to do that, categories are for that, a way to group posts. Why not exclude a category from the blog home page?. With that visitors can see the posts, the bots will be able to index them, the will be listed in searches or category listing, but still be hidden from the homepage.

Turns out there is a pretty simple way to do that. it’s just adding a function to your theme “functions.php” to exclude that particular category.

(?? = category id number)

[code language=”php”]
function exclude_category($query) {
if ( $query->is_home )
$query->set(‘cat’, ‘-??’);
return $query;
add_filter(‘pre_get_posts’, ‘exclude_category’);

The minus sign in front of the category id means don’t include.