the_author_link()
云策文档标注
概述
the_author_link() 是 WordPress 中用于输出作者链接或姓名的模板函数。如果作者设置了主页,则输出 HTML 链接,否则仅输出作者姓名。
关键要点
- 函数 the_author_link() 直接输出作者链接或姓名,基于作者主页设置情况
- 内部调用 get_the_author_link() 函数来获取链接或姓名
- 首次引入于 WordPress 2.1.0 版本
- 相关函数包括 get_the_author_link(),位于 wp-includes/author-template.php 文件中
代码示例
Written by: <?php the_author_link(); ?>示例中,如果作者 James Smith 设置了主页,则输出链接;否则仅显示 "James Smith"。
原文内容
Displays either author’s link or author’s name.
Description
If the author has a home page set, echo an HTML link, otherwise just echo the author’s name.
Source
function the_author_link() {
echo get_the_author_link();
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |
Skip to note 2 content
Codex
Example
Displays the author’s Website URL as a link and the text for the link is the author’s Profile Display name publicly as field. In this example, the author’s Display Name is James Smith.
<p>Written by: </p>Which displays as:
Written by: James Smith