How do I hide a category from blog posts?
Thanks
Mark
hide category from posts
Started by
steelmayhem
, Jun 16 2011 03:44 PM
5 replies to this topic
#1
Posted 16 June 2011 - 03:44 PM
#2
Posted 16 June 2011 - 06:36 PM
http://codex.wordpre..._Your_Home_Page
You could add this code using a filter hook in the functions.php file of your child theme.
hook location : pagelines_before_theloop
#3
Posted 16 June 2011 - 08:49 PM
is this for all? is there a way to hide specified categories? say I have 5 and i dont want one of them.
#4
Posted 17 June 2011 - 02:27 AM
If you want to one specific category, you can. Just add the category ID for that one category you want to hide (and not any category IDs).
#5
Posted 23 January 2012 - 05:03 PM
Please correct me if I'm wrong, but I found this code elsewhere and modified it to filter out a couple categories from my blog and rss feed.
// Hide Category from feed //
function myFeedExcluder($query) {
if ($query->is_feed) {
$query->set('cat','-28,-312,-196');
}
return $query;
}
add_filter('pre_get_posts','myFeedExcluder');
// Hide Category from blog //
function exclude_category($query) {
if ( $query->is_home()) {
$query->set('cat', '-28,-312,-196');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');
#6
Posted 23 January 2012 - 05:12 PM
This thread is very old so if you have a question, make sure you start a new discussion. Thanks










