The meta query below almost works. It isn’t comparing numbers correctly.
In a query where $min=50 and $max=99, it returns a product with a value of 750 (or 751). It doesn’t return products with a value of ‘5’
In a query where $min=500 and $max=999, it returns a product with a value of 60.
It seems to only be comparing the first two digits. When I print the values of the keys they look correct. Does anyone have any insight on what’s happening here?
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'meta_query' => array(
array(
'key' => '_regular_price',
'value' => array($min,$max),
'meta_type'=>'NUMERIC',
'compare' => 'BETWEEN'
)
)
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
woocommerce_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
Thank you E