钩子文档

the_author

💡 云策文档标注

概述

the_author 是一个 WordPress 过滤器,用于修改当前文章作者的显示名称。它允许开发者通过 apply_filters 钩子自定义作者名称的输出。

关键要点

  • the_author 是一个过滤器钩子,作用于当前文章作者的显示名称。
  • 参数 $display_name 是一个字符串,表示作者的显示名称。
  • 源代码中,它通过 apply_filters 调用,基于 $authordata 对象返回 display_name 或空字符串。
  • 相关函数包括 get_the_author(),用于检索当前文章的作者。
  • 该钩子自 WordPress 2.9.0 版本引入。

📄 原文内容

Filters the display name of the current post’s author.

Parameters

$display_namestring
The author’s display name.

Source

return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : '' );

Changelog

Version Description
2.9.0 Introduced.