Ignore Categories on default homepage?

Posted in: Newspaper
Post count: 45

I have the homepage setup not using a page but the default showing all posts. What I want to do is have the homepage list of articles ignore posts in the video category. Any thoughts or where I need to add the code would be greatly appreciated.

Post count: 3343

Hi,
Can you show me a link to see exactly how is your homepage, do you mean you use like here: http://screencast.com/t/dBC8l732sgU

Thanks!

Post count: 45

Yes, the homepage is android-advice.com. Thank you for taking a look.

Post count: 45

Ok so I created a function and added it to the template as follows and it works perfectly:

function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-6575');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');

With the 6575 being the category ID you want to have ignored. Figured I would post for anyone looking for the same thing in the future.

Post count: 854

hi,

thank you for sharing this answer.

Thanks for you message.
Radu A.

Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.