Select multiple categories with is_tax

i have a good function for exclude out of stock products from category. The problem is i want exclude for more than one category (really i want show only in one category, but i think this is the way. If someones know how show only in one category…). Here is the code. thanks!

/* Hyde out of stock product specific category */

add_filter( ‘pre_get_posts’, ‘hide_out_of_stock_from_cat’ );
function hide_out_of_stock_from_cat( $query ) {
if ( $query->is_tax( ‘product_cat’, 15 ) && $query->is_main_query() ) {
$query->set( ‘meta_query’, array(array(
‘key’ => ‘_stock_status’,
‘value’ => ‘outofstock’,
‘compare’ => ‘NOT IN’

Read more here:: Select multiple categories with is_tax

Leave a Reply

Your email address will not be published. Required fields are marked *