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() );
腾讯云
限时秒杀【点击购买】
搬瓦工,CN2
高速线路,1GB
带宽,电信联通优化KVM
,延迟低,速度快,建站稳定,搬瓦工BandwagonHost VPS优惠码BWH26FXH3HIQ
,支持<支付宝> 【点击购买】!
Vultr$3.5
的日本
节点,512M
内存/500G
流量/1G
带宽,电信联通优化,延迟低,速度快【点击购买】!
阿里云
香港、新加坡
VPS/1核/1G/25G SSD
/1T
流量/30M
带宽/年付¥288
【点击购买】