钩子文档

post_date_column_time

💡 云策文档标注

概述

post_date_column_time 是一个 WordPress 过滤器,用于修改文章在列表视图中显示的发布时间、预定时间或未发布时间的字符串。它允许开发者自定义时间格式或内容,基于文章对象和显示模式。

关键要点

  • 过滤器名称:post_date_column_time,用于过滤文章日期列的时间字符串。
  • 参数:包括时间字符串 $t_time、文章对象 $post、列名 $column_name 和显示模式 $mode。
  • 应用场景:主要在 WP_Posts_List_Table::column_date() 方法中调用,控制后台文章列表的日期输出。
  • 版本变化:WordPress 5.5.0 移除了 'excerpt' 和 'list' 模式的区别,现在统一显示发布时间和日期,相当于之前的 'excerpt' 模式。

注意事项

从 WordPress 5.5.0 开始,此过滤器的 $mode 参数不再区分 'excerpt' 和 'list' 模式,开发者应确保代码兼容此变化。


📄 原文内容

Filters the published, scheduled, or unpublished time of the post.

Parameters

$t_timestring
The published time.
$postWP_Post
Post object.
$column_namestring
The column name.
$modestring
The list display mode ('excerpt' or 'list').

Source

echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );

Changelog

Version Description
5.5.0 Removed the difference between 'excerpt' and 'list' modes.
The published time and date are both displayed now, which is equivalent to the previous 'excerpt' mode.
2.5.1 Introduced.