admin管理员组文章数量:1287930
Right now I have this:
$args = array(
'meta_key' => 'userfunds',
'meta_value' => '0',
);
Basically this will show users who have exactly '0' as meta_value
.
How do I say that meta_value
has to be greater than '0'?
I have tried:
'meta_value' > '0',
But using the above, it shows all users, regardless of their value.
So I guess using >
in the array is an invalid line and not what I need.
I know I'm probably missing something very small in my code?
should I use compare
?
Any help would be appreciated.
Right now I have this:
$args = array(
'meta_key' => 'userfunds',
'meta_value' => '0',
);
Basically this will show users who have exactly '0' as meta_value
.
How do I say that meta_value
has to be greater than '0'?
I have tried:
'meta_value' > '0',
But using the above, it shows all users, regardless of their value.
So I guess using >
in the array is an invalid line and not what I need.
I know I'm probably missing something very small in my code?
should I use compare
?
Any help would be appreciated.
Share Improve this question asked Sep 14, 2021 at 18:46 robert0robert0 2032 silver badges11 bronze badges1 Answer
Reset to default 1As documented, you can use meta_compare
:
$args = array(
'meta_key' => 'userfunds',
'meta_value_num' => '0',
'meta_compare' => '>',
);
Note that I changed meta_value
to meta_value_num
. This ensures the values is treated as a number for the comparison. You'd probably be ok without it, but it doesn't hurt.
本文标签: phpHow to say if metavalue is greater than 0 in an array
版权声明:本文标题:php - How to say if meta_value is greater than 0 in an array? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741320548a2372180.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论