首页 > WordPress学习 > WordPress 显示当前文章作者名称以及昵称 the_author();失效怎么办

WordPress 显示当前文章作者名称以及昵称 the_author();失效怎么办

时间:2023年3月15日 分类:WordPress学习 浏览量:323

我们在制作文章模板时,有时需要展示文章作者信息,比如作者名称,昵称等。一般,我们最开始想到的是:

<?php the_author(); ?>

但发现,无法展示,再试试昵称:

<?php the_author_nickname(); ?>

也没法实现

经过查找,发现需要使用“get_the_author_meta()”函数来实现:

<?php echo get_the_author_meta( 'nickname', $post->post_author ); ?>

如此,我们就成功将作者的昵称展示出来了

作者信息相关参数:

user_login(用户登录名)
user_pass(用户登录密码)
user_nicename(用户昵称)
user_email(用户邮箱地址)
user_url(用户网站地址)
user_registered(用户注册时间)
user_status(用户状态)
display_name(作者显示的名称)
nickname(作者昵称)
first_name(作者名字)
last_name(作者姓氏)
description(作者描述)
user_level(用户等级)
user_firstname(用户名字)
user_lastname(用户姓氏)
user_description(用户描述)

作者信息调用相关:

<?php the_author(); ?> 显示文章的作者
<?php the_author_description(); ?> 显示文章作者的描述(作者个人资料中的描述)
<?php the_author_login(); ?> 显示文章作者的登录名
<?php the_author_firstname(); ?> 显示文章作者的firstname(名)
<?php the_author_lastname(); ?> 显示文章作者的lastname(姓)
<?php the_author_nickname(); ?> 显示文章作者的昵称
<?php the_author_ID(); ?> 显示文章作者的ID号
<?php the_author_email(); ?> 显示文章作者的电子邮箱
<?php the_author_url(); ?> 显示文章作者的网站地址
<?php the_author_link (); ?>(添加于2.1版本) 显示一个以文章作者名为链接名,链接地址为文章作者的网址的链接。
<?php the_author_icq(); ?> (不推荐使用) 显示文章作者的icq
<?php the_author_aim(); ?> 显示文章作者的aim
<?php the_author_yim(); ?> 显示文章作者的yim
<?php the_author_msn(); ?> (不推荐使用) 显示文章作者的msn
<?php the_author_posts(); ?> 显示文章作者已发表文章的篇数
<?php the_author_posts_link(); ?> 显示一个链接到文章作者已发表文章列表的链接

我们可以根据需要来展示

版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权

文章名称:WordPress 显示当前文章作者名称以及昵称 the_author();失效怎么办

文章链接:https://news.yynnw.com/149.html

该作品系作者结合个人学习经验及互联网相关知识整合。如若侵权请通过投诉通道提交信息,我们将按照规定及时处理。

觉得文章有用就打赏一下文章作者

微信扫一扫打赏

标签:

最新文章