is_home && $query->is_main_query() ) { $cafeteria_elementor_exclude_categories = cafeteria_elementor_get_option( 'exclude_categories' ); if ( ! empty( $cafeteria_elementor_exclude_categories ) ) { $cats = explode( ',', $cafeteria_elementor_exclude_categories ); $cats = array_filter( $cats, 'is_numeric' ); $cafeteria_elementor_string_exclude = ''; if ( ! empty( $cats ) ) { $cafeteria_elementor_string_exclude = '-' . implode( ',-', $cats); $query->set( 'cat', $cafeteria_elementor_string_exclude ); } } } return $query; } endif; add_filter( 'pre_get_posts', 'cafeteria_elementor_exclude_category_in_blog_page' );