the_author_posts()
云策文档标注
概述
the_author_posts() 是一个 WordPress 模板标签,用于直接输出当前文章作者的文章数量。它基于 get_the_author_posts() 函数实现,适用于主题开发中显示作者信息。
关键要点
- the_author_posts() 直接输出作者文章数量,无返回值
- 内部调用 get_the_author_posts() 函数来获取数据
- 自 WordPress 0.71 版本引入,位于 wp-includes/author-template.php 文件中
- 常用于作者档案页或单篇文章页,结合其他作者相关标签使用
代码示例
<?php the_author_posts(); ?>注意事项
使用时需确保在 WordPress 循环内,以正确获取当前文章的作者信息。输出为纯数字,无格式化,如需自定义显示格式,可结合其他函数或直接使用 get_the_author_posts()。
原文内容
Displays the number of posts by the author of the current post.
Source
function the_author_posts() {
echo get_the_author_posts();
}
Changelog
| Version | Description |
|---|---|
| 0.71 | Introduced. |
Skip to note 2 content
Codex
Basic Example
Displays the author’s name and number of posts.
<p> has blogged posts</p>Output is “Harriett Smith has blogged 425 posts.”