Excluding categories from different pages
-
Ok so i found the code which excludes posts from the homepage but i wanted to alter it so that it excluded categories form different pages as you can see on my website my homepage
critgaming.com and
critgaming.com/minecraftare completely different times and i want different categories as the main page is a template for a different pages and i will need different categories for atleast 6 different pages.
function exclude_category($query) {
if ( $query->is_home ) {
$query->set(‘cat’, ‘-xx’);
}
return $query;
}
add_filter(‘pre_get_posts’, ‘exclude_category’);so how can i edit this to exclude from a different page than home.
categories are are home (id 1) and minecraft (id 8) and page slug is minecraft
The topic ‘Excluding categories from different pages’ is closed to new replies.