开发者

Wordpress, List Authors and Exclude Admin

开发者 https://www.devze.com 2023-01-12 19:45 出处:网络
I am trying to loop through authors in my wordpress blog but something weird keeps happening, probably because I haven\'t fully grasped how to use the functions. When I do this:

I am trying to loop through authors in my wordpress blog but something weird keeps happening, probably because I haven't fully grasped how to use the functions. When I do this:

$authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
if($authors):
foreach($authors as $author):
if(the_author_meta('display_name', $author->post_author) != 'admin'): //my line

I am trying to exclude the "admin" user from my loop, but when I execute this. I get the all authors names shown twice on the page including the admin. So the conditional is n开发者_如何学Goot acting as a conditional but rather an echo!

What I am doing wrong?

Thanks all


Use get_the_author_meta(), and and not the_author_meta(). The one you're using echos results to the browser as part of the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号