Skip to content

Instantly share code, notes, and snippets.

@hemraj7171
Created December 15, 2016 11:47
Show Gist options
  • Save hemraj7171/3209ad4b9a5a44b242fdae5208fcdab0 to your computer and use it in GitHub Desktop.
Save hemraj7171/3209ad4b9a5a44b242fdae5208fcdab0 to your computer and use it in GitHub Desktop.
Price Different Range Query
<?php
function product_price_loop( $priceArray ) {
$arr = array( 'relation' => 'OR' );
/*$output['output'] = print_pre($arr);
return $output; */
foreach( $priceArray as $key => $value ) {
$price_range = explode( '-', $value );
# code...
$arr[$key] = array(
'key' => '_regular_price',
'value' => array( $price_range[0], $price_range[1] ),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
);
}
return $arr;
}
$args['meta_query'] = product_price_loop( $pram['product_price'] );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment