Skip to main content
added 5 characters in body
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

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 );

$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)$wpdb->get_results($sql,OBJECT) or is there a better way?

From SQL we have:

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2; 

Does the SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2; WP_query Does the WP_query class have a method to use the BETWEENBETWEEN keyword inside a query?

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?

From SQL we have:

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2; Does the WP_query class have a method to use the BETWEEN keyword inside a query?

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?

From SQL we have:

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2; 

Does the WP_query class have a method to use the BETWEEN keyword inside a query?

added 207 characters in body
Source Link

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?

From SQL we have:

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2; Does the WP_query class have a method to use the BETWEEN keyword inside a query?

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?

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?

From SQL we have:

SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2; Does the WP_query class have a method to use the BETWEEN keyword inside a query?

Source Link

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?