WordPress Exclude Category from Home Function

<?php

function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-2, -26' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' ); 

?>

Leave a Reply