@alchymyth
When I excluded 1 category this worked great:
/* Exclude category'viewer-video-requests' from the Blog Page */
function main_page_exclude_category_offers( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$cat_offers = get_term_by('slug','viewer-video-requests','category');
$query->set( 'cat', '-'.$cat_offers->term_id );
}
}
add_action('pre_get_posts','main_page_exclude_category_offers');
Now, I want to exclude 2 categories & tried this, but it didn’t work:
/* Exclude category'viewer-video-requests' from the Blog Page */
function main_page_exclude_category_offers( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$cat_offers = get_term_by('slug','viewer-video-requests','category');
$query->set( 'cat', '-'.$cat_offers->term_id );
}
else if ( $query->is_home() && $query->is_main_query() ) {
$cat_offers = get_term_by('slug','closed-viewer-video-requests','category');
$query->set( 'cat', '-'.$cat_offers->term_id );
}
}
add_action('pre_get_posts','main_page_exclude_category_offers');
I’m a PHP dummy. Can anyone offer any help? I need to exclude 2 categories. Thank you!!!