Exclude Categories In Parent?
-
I’m using this code in my functions.php to exclude posts from the front page and archives:
function exclude_category($query) { if ( $query->is_archive || $query->is_home) { $query->set('cat', '-18 -20 -24 -26'); } return $query; } add_filter('pre_get_posts', 'exclude_category');
18 is a parent category and 20 and 24 are children of that category. I’d like to exclude all children in category 18 because I’ll be adding categories to that parent and don’t want to manually add them every time I do. I’ve tried everything I can think of using
child_of
and can’t make it happen. Any suggestions would be appreciated.PS: Same goes for the smartarchives plugin. I’ve tried everything I can think of on this line:
$catID='18'; // the category(ies) you do *not* want to be displayed in your archives
and nada :\
Viewing 15 replies - 1 through 15 (of 15 total)
Viewing 15 replies - 1 through 15 (of 15 total)
- The topic ‘Exclude Categories In Parent?’ is closed to new replies.