函数文档

the_author_posts_link()

💡 云策文档标注

概述

the_author_posts_link() 是一个 WordPress 模板标签,用于在循环中输出当前文章作者页面的 HTML 链接。该函数自 4.4.0 版本起已转换为 get_the_author_posts_link() 的包装器。

关键要点

  • 函数功能:显示指向当前文章作者页面的 HTML 链接,链接文本默认为作者的显示名称。
  • 参数:接受一个已弃用的参数 $deprecated,自 2.1.0 版本起不再使用,若传入会触发 _deprecated_argument() 警告。
  • 相关函数:内部调用 get_the_author_posts_link() 来获取链接,并直接输出结果。
  • 版本历史:在 1.2.0 版本引入,4.4.0 版本重构为包装器以提高代码一致性。

代码示例

// 在 WordPress 循环中使用
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        the_author_posts_link(); // 输出作者链接
    endwhile;
endif;

注意事项

  • 必须在 WordPress 主循环内调用,以确保能正确获取当前文章的作者信息。
  • 参数 $deprecated 已弃用,建议避免传递任何值以防止触发弃用警告。
  • 如需自定义链接或获取链接字符串而不直接输出,应使用 get_the_author_posts_link() 函数。

📄 原文内容

Displays an HTML link to the author page of the current post’s author.

Parameters

$deprecatedstringrequired
Unused.

Source

function the_author_posts_link( $deprecated = '' ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.1.0' );
	}
	echo get_the_author_posts_link();
}

Changelog

Version Description
4.4.0 Converted into a wrapper for get_the_author_posts_link()
1.2.0 Introduced.

User Contributed Notes