SHARE
TWEET

WooCommerce - Show only products below a certain price

lorro Jan 31st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // WooCommerce - Show only products below a certain price
  3. add_action( 'woocommerce_product_query', 'custom_product_query' );
  4. function custom_product_query( $query ) {
  5.   $meta_query = $query->get( 'meta_query' );
  6.   $meta_query[] = array(
  7.     'key'     => '_price',
  8.     'value'   => 20,
  9.     'compare' => '<=',
  10.     'type'    => 'NUMERIC'
  11.   );
  12.   $query->set( 'meta_query', $meta_query );
  13. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top