taxonomy; $categories_ids = array_map( function( $item ) { return $item['value']; }, $categories_raw ); $tax_slugs_of_catch_all_items = []; $is_any_catch_all_selected = false; foreach ( $categories_raw as $item ) { if ( true === $item['isCatchAll'] ) { $tax_slugs_of_catch_all_items[] = $item['groupSlug']; $is_any_catch_all_selected = true; } } // Logic evaluation. $current_category_id = get_queried_object_id(); $is_displayable = array_intersect( $categories_ids, (array) $current_category_id ) ? true : false; if ( ! $is_displayable && $is_any_catch_all_selected ) { $is_displayable = array_intersect( $tax_slugs_of_catch_all_items, (array) $queried_taxonomy ) ? true : false; } // Evaluation output. return ( 'is' === $display_rule ) ? $is_displayable : ! $is_displayable; } }