get_the_author_meta()
get_the_author_meta( string $field = ”, int|false $user…
get_the_author_meta( string $field = ”,  int|false $user_id = false )
检索当前文章作者的请求数据。
Retrieves the requested data of the author of the current post.
检索当前文章作者的请求数据。
Retrieves the requested data of the author of the current post.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
$field参数的有效值包括:
管理颜色
目标
评论快捷方式
描述
显示名称
名字
身份证件
叽叽喳喳
姓氏
昵称
插件最后一个视图
每个页面的插件
富库编辑
语法突出显示
用户激活密钥
用户描述
用户电子邮件
用户名
用户名
用户级别
用户登录
用户名
用户通行证
用户注册
用户状态
用户url
伊姆
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| $field | (string) | 可选 | 要检索的用户字段。 | 
| $user_id | (int | false) | 可选 | 用户ID。 | 
返回(Return)
(string)当前作者的DB对象中的作者字段,否则为空string。
源码(Source)
/**
 * Retrieve the requested data of the author of the current post.
 * @link https://codex.wordpress.org/Template_Tags/the_author_meta
 * @since 2.8.0
 *
 * @global object $authordata The current author's DB object.
 *
 * @param string $field selects the field of the users record.
 * @param int $user_id Optional. User ID.
 * @return string The author's field from the current author's DB object.
 */
function get_the_author_meta( $field = '', $user_id = false ) {
	$original_user_id = $user_id;
	if ( ! $user_id ) {
		global $authordata;
		$user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
	} else {
		$authordata = get_userdata( $user_id );
	}
	if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
		$field = 'user_' . $field;
	$value = isset( $authordata->$field ) ? $authordata->$field : '';
	/**
	 * Filter the value of the requested user metadata.
	 *
	 * The filter name is dynamic and depends on the $field parameter of the function.
	 *
	 * @since 2.8.0
	 * @since 4.3.0 The `$original_user_id` parameter was added.
	 *
	 * @param string   $value            The value of the metadata.
	 * @param int      $user_id          The user ID for the value.
	 * @param int|bool $original_user_id The original user ID, as passed to the function.
	 */
	return apply_filters( 'get_the_author_' . $field, $value, $user_id, $original_user_id );
}| 更新版本 | 源码位置 | 使用 | 被使用 | 
|---|---|---|---|
| 2.8.0 | wp-includes/author-template.php:160 | 23 | 3 | 
笔记(Notes)
显示作者简介(说明)并保持换行符
获取循环外的作者ID:
获取作者ID:
类别:WordPress 函数手册、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。



还没有任何评论,赶紧来占个楼吧!