WordPress-仅在编辑者角色中显示author.php中的Bio [英] Wordpress - show Bio in author.php only for Editor role

查看:135
本文介绍了WordPress-仅在编辑者角色中显示author.php中的Bio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 author.php 页面,该页面必须根据帖子作者的角色而有所不同。如果角色是 Editor Admin ,则将显示个人简介。否则(例如对于作者)则不是。但是我在任何地方都找不到。我有使用 get_userdata 的提示,但是却无法做到。

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.

感谢您的帮助!

推荐答案

您可以全局检查 $ wp_query 来获得作者的角色:

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
}

这篇关于WordPress-仅在编辑者角色中显示author.php中的Bio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆