wordpress教程之the_author_meta()显示用户的信息

时间:2021-03-16 08:40:27

描述

模板标签函数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(作者描述)
  • description_s(作者简介)
  • user_level(用户等级)
  • user_firstname(用户名字)
  • user_lastname(用户姓氏)
  • user_description(用户描述)
  • ID(用户ID值)

例子

<?php  echo the_author_meta( 'description' ); ?>

//获取作者的描述内容

<?php  echo the_author_meta( 'user_email' ); ?>

//获取作者的邮箱地址