Wordpress - show Bio in author.php only for Editor

2019-08-28 02:47发布

I have an author.php page that must look differently according to post author's role. If it's role is Editor or Admin, the bios is shown. Otherwise (for Author, for example), it is not. But I can't find it anywhere. I had a clue to use get_userdata, but couldn't manage to do so.

Thanks for the help!

1条回答
小情绪 Triste *
2楼-- · 2019-08-28 03:24

You can check the $wp_query global to get the author's role:

global $wp_query;
$roles = $wp_query->queried_object->roles;
if( $roles[0] == 'editor' ) {
    // do stuff
}
查看更多
登录 后发表回答