admin管理员组文章数量:1287833
So I'm building this post query array:
$posts = get_posts(array(
'author' => $publisher_info-ID,
'post_type' => 'post',
'posts_per_page' => 150,
'meta_query' => array(
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => array( 'campaign' ),
),
array(
'key' => 'status',
'value' => 'active',
),
),
'orderby' => 'rand'
));
What I'm struggling is how to integrate two meta key comparison?
Let's say I have two meta keys meta_key
A1 and meta_key
A2.
Both have numbers in their meta_value
.
What I want is to incorporate: A1 < A2 in the array.
Any help would be appreciated.
So I'm building this post query array:
$posts = get_posts(array(
'author' => $publisher_info-ID,
'post_type' => 'post',
'posts_per_page' => 150,
'meta_query' => array(
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => array( 'campaign' ),
),
array(
'key' => 'status',
'value' => 'active',
),
),
'orderby' => 'rand'
));
What I'm struggling is how to integrate two meta key comparison?
Let's say I have two meta keys meta_key
A1 and meta_key
A2.
Both have numbers in their meta_value
.
What I want is to incorporate: A1 < A2 in the array.
Any help would be appreciated.
Share Improve this question asked Sep 15, 2021 at 9:18 robert0robert0 2032 silver badges11 bronze badges 1 |1 Answer
Reset to default -1Use this type of code :
$args = array(
'author' => $publisher_info->ID,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'type',
'field' => 'slug',
'terms' => array( 'campaign' ),
)
),
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'status',
'value' => 'active',
'compare' => '='),
array(
'key' => 'B',
'value' => '1',
'compare' => '!=')
)
);
$data = new WP_Query($args);
本文标签: phpHow to set if metavalue is lower lt than other metavalue in a getposts array
版权声明:本文标题:php - How to set if meta_value is lower < than other meta_value in a get_posts array? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741319493a2372120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
meta_query
contains a taxonomy query that should be in thetax_query
arg, and you're also missing>
here:$publisher_info-ID
... – Sally CJ Commented Sep 15, 2021 at 9:30