Skip to main content
1 of 3

Query with a meta value inside a given range

Quick question: I would like to retrieve some pages/posts with a meta value inside a range, eg) $min<$meta_value<$max

for ordinary $meta_value there was a way to get pages/posts like this:

$args = array( 'meta_key' => $key, 'meta_value' => $meta_value, //$min<$meta_value<$max 'post_type' => 'page', 'post_status' => 'publish', ... ); $pages = get_pages( $args );

What is the best solution? should I first get them all and check them in an if condition or should I use $wpdb->get_results($sql,OBJECT) or is there a better way?