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.
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.
- Can you format your code with newlines and indentation? It's all written on a single line making it extremely difficult to read – Tom J Nowell ♦ Commented Jul 1, 2020 at 21:11
- Ok I have done this now – JoaMika Commented Jul 2, 2020 at 9:28
1 Answer
Reset to default 1Try 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'
);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742298877a4417665.html
评论列表(0条)