Pages

05 June, 2023

WP_Query stock status filter Wordpress

I have this WP_Query code that shows me results if the value of _pre_orders_enabled does not exist or has the value no What I want is that I also filter it by _stock_status I tried this but it didn't work. My code: $products = new WP_Query( array( 'post_type' => 'product', 'starts_with' => $letra, 'posts_per_page' => -1, 'order' => 'DESC', 'meta_query' => array( 'relation' => 'OR', array( 'key' => '_pre_orders_enabled', 'value' => 'no', 'compare' => '=', ), array( 'key' => '_pre_orders_enabled', 'compare' => 'NOT EXISTS', ), ), ) ); I tried to filter by array( 'key' => '_stock_status', 'value' => 'instock', 'compare' => '=', ), but it didn't work

No comments:

Post a Comment

Thanks