根据documentation, 方法get_the_author_meta()
有一个$field
具有以下可能值的参数:
管理颜色aim注释快捷方式描述显示每页的插件编辑语法突出显示/li>
- 我想知道
last_name
和user_lastname
(first_name
和user_firstname
分别)。Which property am I supposed to use 其中一个可能被填补,而另一个可能被填补的原因是什么?
根据documentation, 方法get_the_author_meta()
有一个$field
具有以下可能值的参数:
管理颜色aim注释快捷方式描述显示每页的插件编辑语法突出显示/li>
last_name
和user_lastname
(first_name
和user_firstname
分别)。Which property am I supposed to use 其中一个可能被填补,而另一个可能被填补的原因是什么?
“我应该使用哪个属性”的简短回答:Use first_name
and last_name
.
first_name
, user_firstname
, last_name
和user_lastname
定义在WP_User
class, 尽管名称不同(即user_
另一个没有前缀):两者first_name
和user_firstname
使用first_name
元last_name 和user_lastname
使用last_name
元user_firstname 和user_lastname
WordPress中是否使用了2.0.0版之前的属性名称(14年前…)-看见get_the_author_firstname()
和get_the_author_lastname()
here 和here, 这些属性是still supported for backward compatibility, 但是我们应该只使用那些没有user_
前缀(例如。first_name
而不是user_firstname
).
// Both of these return the same value - the value of the meta named first_name.
var_dump(
get_the_author_meta( \'user_firstname\' ), // works
get_the_author_meta( \'first_name\' ) // but better
);
// Both of these return the same value - the value of the meta named first_name.
$current_user = wp_get_current_user();
var_dump(
$current_user->user_firstname, // works
$current_user->first_name // but better/shorter...
);
我正在尝试将作者姓名显示为标记。我看了很多论坛,它指的是get_author 方法和模板PHP中的PHP文件。然而,我不知道在get_author 方法,以便将其名称作为简单博客文章的标记返回。我查看了以下参考资料:https://codex.wordpress.org/Template_Tags#Author_tagshttps://codex.wordpress.org/Function_Reference/the_author</我不知道要编辑哪些文件,把它放在哪里,因为PHP不是我的通用语言