Exclude category in home and other collections

To exclude categories in any queries in the homepage.  Add following code themes functions.php file. Other possibilities can be found in here. This is a useful example if you what make Uncategorized category hidden.

function exclude_category( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-1,-2' );
return $query;
add_filter( 'pre_get_posts', 'exclude_category' );

Leave a Reply

Your email address will not be published.