the_author_meta()获取作者信息函数-wordpress教程

函数:the_author_meta(显示作者相关信息)

描述:模板标签函数the_author_meta可以显示用户数据。如果该函数在文章主循环(Loop)中,则不必指定作者的ID值,标签所显示的就是当前文章作者的内容。如果在主循环(Loop)外,则需要指定用户ID值。

注:如果需要显示用户信息但是不想显示出来(比如用在php方法中),请使用get_the_author_meta()方法。

<?php the_author_meta( $field, $userID );?>

参数说明:
 
$field(字符串)将要显示的用户信息的字段名称(这些在数据库中都可以找到)。常用到的有:

user_login(用户登录名)

user_pass(用户登录密码)

user_nicename(用户昵称)

user_email(用户邮箱地址)

user_url(用户网站地址)

user_registered(用户注册时间)

user_status(用户状态)

display_name(作者显示的名称)

nickname(作者昵称)

first_name(作者名字)

last_name(作者姓氏)

description(作者描述)

user_level(用户等级)

user_firstname(用户名字)

user_lastname(用户姓氏)

user_description(用户描述)

ID(用户ID值)

例子:

<?php  echo the_author_meta('user_email');?>
//获取作者的邮箱地址
<?php  echo the_author_meta('user_nicename');?>
//获取作者的昵称

这样就可以获得作者的相关信息了,如果我们想在自己的网站上面加上作者的介绍,就可以使用这个方法


如果……

注意:如果需要返回(不显示)用户信息,请使用get_the_author_meta()。

文章由官网发布,如若转载,请注明出处:https://www.veimoz.com/886
0 评论
2.3k

发表评论

!