This code worked perfect for me with one change:
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '-17' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );
the ‘-‘ is not needed to remove the category, when the ‘-‘ was present it only displayed that category.
Here is the exact code used:
function exclude_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'cat', '3' );
}
}
add_action( 'pre_get_posts', 'exclude_category' );
I’m guessing that the ‘exclude_category’ and the ‘-‘ were two opposites which caused it to filter all except cat 3.