Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('woocommerce_product_query', 'custom_product_query');
- function custom_product_query($q)
- {
- if (!$q->is_main_query()) return;
- $q->set('meta_query', array(
- 'relation' => 'OR',
- array(
- 'key' => '_stock_status',
- 'value' => 'instock',
- 'compare' => '=',
- ),
- array(
- 'key' => '_stock_status',
- 'value' => 'outofstock',
- 'compare' => '=',
- ),
- ));
- $q->set('orderby', 'meta_value');
- $q->set('order', 'ASC');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement