admin管理员组文章数量:1130349
How to get the count of the WP_User_Query result
while I use
$query = new WP_User_Query( $args );
echo count($query);
It returns 1 when there is no user. But I need 0 in that case.
How can I get the count of users?
How to get the count of the WP_User_Query result
while I use
$query = new WP_User_Query( $args );
echo count($query);
It returns 1 when there is no user. But I need 0 in that case.
How can I get the count of users?
Share Improve this question edited Nov 1, 2018 at 10:42 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 1, 2018 at 8:26 Sammu SundarSammu Sundar 1033 bronze badges1 Answer
Reset to default 2You should use a total_users property:
$query = new WP_User_Query( $args );
$query->total_users;
or get_total method:
$query = new WP_User_Query( $args );
$query-> get_total();
Docs are your friend: https://codex.wordpress/Class_Reference/WP_User_Query
How to get the count of the WP_User_Query result
while I use
$query = new WP_User_Query( $args );
echo count($query);
It returns 1 when there is no user. But I need 0 in that case.
How can I get the count of users?
How to get the count of the WP_User_Query result
while I use
$query = new WP_User_Query( $args );
echo count($query);
It returns 1 when there is no user. But I need 0 in that case.
How can I get the count of users?
Share Improve this question edited Nov 1, 2018 at 10:42 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Nov 1, 2018 at 8:26 Sammu SundarSammu Sundar 1033 bronze badges1 Answer
Reset to default 2You should use a total_users property:
$query = new WP_User_Query( $args );
$query->total_users;
or get_total method:
$query = new WP_User_Query( $args );
$query-> get_total();
Docs are your friend: https://codex.wordpress/Class_Reference/WP_User_Query
本文标签: usersHow to get the count
版权声明:本文标题:users - How to get the count 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749214792a2333980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论