钩子文档

get_the_time

💡 云策文档标注

概述

get_the_time 是一个 WordPress 过滤器,用于修改或过滤文章的时间输出。它允许开发者自定义时间格式或基于特定条件调整时间字符串。

关键要点

  • 过滤器名称:get_the_time
  • 参数:$the_time(格式化日期字符串或 Unix 时间戳)、$format(时间格式,如 'G'、'U' 或 PHP 日期格式)、$post(WP_Post 对象)
  • 返回值:应用过滤器后的时间字符串
  • 相关函数:get_the_time() 用于检索文章时间

代码示例

apply_filters( 'get_the_time', $the_time, $format, $post );

注意事项

  • 在 WordPress 1.5.0 版本中引入
  • 可用于主题或插件开发中自定义时间显示逻辑

📄 原文内容

Filters the time of the post.

Parameters

$the_timestring|int
Formatted date string or Unix timestamp if $format is 'U' or 'G'.
$formatstring
Format to use for retrieving the time the post was written. Accepts 'G', 'U', or PHP date format.
$postWP_Post
Post object.

Source

return apply_filters( 'get_the_time', $the_time, $format, $post );

Changelog

Version Description
1.5.0 Introduced.