我需要调用帖子作者的用户名.
我已经try 了WordPress: get author info from post id个应答代码.
我已经在POST循环中添加了代码, echo 为$display_name
.
它可以工作,但不是为了我需要的,因为它显示了昵称.
所以我试着把‘昵称’改为‘用户名’,如下所示:
$post_id = get_the_ID();
$author_id = get_post_field ('post_author', $post_id);
$display_name = get_the_author_meta( 'username' , $author_id );
但这并没有奏效.