最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - How to display only author's name for the current post?

programmeradmin11浏览0评论

I want to just show the author's name (unlinked to author archive).

I don't want to show the author's avatar.

I have used some plugins but I got failed.

I want to just show the author's name (unlinked to author archive).

I don't want to show the author's avatar.

I have used some plugins but I got failed.

Share Improve this question edited Mar 23, 2020 at 10:19 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Mar 21, 2020 at 15:09 Zain Ul AabideenZain Ul Aabideen 11 bronze badge 1
  • Was my answer helpful to you?! Please accept and upvote if was helpful – WordPress Speed Commented Mar 28, 2020 at 16:05
Add a comment  | 

1 Answer 1

Reset to default 0

You may use the the_author_meta function:

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

You may provide $field which is of these values:

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

and is well documented here. In your case you may choose display_name.

Also you may provide the $user_id. If you don't provide it, it will be the current author's DB object (author of current post).

If you want to get the name for some string manipulation and not directly printing on the output, just use get_the_author_meta().

发布评论

评论列表(0)

  1. 暂无评论