Advertisement
majeedraza

WooCommerce - Show only products below a certain price

Jan 31st, 2019
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement