Npcink Blog
切换菜单
本页目录1 节

在代码开发中,会用到文章作者的 ID,这次的 WordPress 开发分享两个方法,可以在 LOOP 内外获取到文章作者的 ID。

LOOP 循环中

官方文档:

get_the_author_meta( string $field = '', int|false $user_id = false )

在循环外面通过以下方法获取用户 ID

$author_id = get_post_field ('post_author', get_the_ID() );