I have this meta query:
$args = array(
'post_type' => 'events',
'meta_query' => array(
array(
'key' => 'fl_type',
'value' => 'Awards'
)
),
'posts_per_page' => -1,
'meta_key' => 'fl_order',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'fields' => 'ids'
);
However I need to extend this by another 2 numeric variables fl_expire = 0 and fl_global = 1 and I can’t figure out the correct syntax for this.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Try this
$args = array(
'post_type' => 'events',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'fl_type',
'value' => 'Awards'
),
array(
'key' => 'fl_expire',
'value' => 0,
'type' => 'NUMERIC',
),
array(
'key' => 'fl_global',
'value' => 1,
'type' => 'NUMERIC',
),
),
'posts_per_page' => -1,
'meta_key' => 'fl_order',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'fields' => 'ids'
);
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0