我如何在WordPress中显示翻译的作者角色名称

问题描述 投票:0回答:1

在functions.php中使用此功能有效,但它显示了子弹名称,例如:administrator

function get_author_role() {
    $userauthorid = get_the_author_meta( 'id' );
    $user_info = get_userdata($userauthorid );
    echo $user_info->roles['name']; 
}

我希望它显示翻译后的角色名称。

php wordpress function translate
1个回答
0
投票

出于此原因添加了[translate_user_role()函数。

translate_user_role($user_info->roles['name']) ;

应该在functions.php中工作

© www.soinside.com 2019 - 2024. All rights reserved.