WordPress 如何获取文章发表用户ID
WordPress插件/主题开发中,如何获取文章发表用户的ID ? LOOP循环中 官方文档: get_the…
WordPress插件/主题开发中,如何获取文章发表用户的ID ?
LOOP循环中
官方文档:
get_the_author_meta( string $field = '', int|false $user_id = false )Retrieves the requested data of the author of the current post.
Description
Valid values for the $field parameter include:
- admin_color
 - aim
 - comment_shortcuts
 - description
 - display_name
 - first_name
 - ID
 - jabber
 - last_name
 - nickname
 - plugins_last_view
 - plugins_per_page
 - rich_editing
 - syntax_highlighting
 - user_activation_key
 - user_description
 - user_email
 - user_firstname
 - user_lastname
 - user_level
 - user_login
 - user_nicename
 - user_pass
 - user_registered
 - user_status
 - user_url
 - yim
 
Parameters
$field
(string) (Optional) The user field to retrieve.
Default value: ”$user_id
(int|false) (Optional) User ID.
Default value: false
Return
(string) The author’s field from the current author’s DB object, otherwise an empty string.
在循环外面通过以下方法获取用户ID
$author_id = get_post_field ('post_author', get_the_ID() );
类别:WordPress教程、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!