Exclude categories from index post page

Description

This code excludes defined categories from the post page. To use this code simply replace -93, -94, -92 with the categories that you would like excluded. This code goes inside the functions.php file at the bottom. dont forget to add the opening and closing php tags. This code was used on the habeshabrides website

This code excludes defined categories from the post page. To use this code simply replace -93, -94, -92 with the categories that you would like excluded. This code goes inside the functions.php file at the bottom. dont forget to add the opening and closing php tags. This code was used on the habeshabrides website

PHP Source Code

                        
                          function exclude_category($query) {
if ( $query->is_home() ) {
$query->set('cat', '-93,-94,-92');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');                        
                        


Post Categories