Excluding Categories
-
I found your support post where you recommended using this function to filter unwanted categories from showing in archive. I’ve used this code:
function my_custom_get_posts( $query ) {
//ignore main query
if ( is_admin() || ! $query->is_main_query() )
return;
//remove cats by id from archive query
if ( $query->is_archive() ) {
$bad_kitty = array(2, 4, 8);
$query->set( ‘post__not_in’, $bad_kitty );
}
}
add_action( ‘pre_get_posts’, ‘my_custom_get_posts’, 1 );Changed the array to = the cats I don’t want to display, but they still show up. If you could send me a PM I’ll send you the link and give you login info if you’d like.
Thank you — it’s a great plugin and will be perfect if I can get this to work!
The topic ‘Excluding Categories’ is closed to new replies.