Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
get_the_date - 过滤发布文章的日期 - WordPress钩子 - WordPress动力
当前浏览:首页 / WordPress钩子 / get_the_date

apply_filters( 'get_the_date', string|int $the_date, string $format, WP_Post $post )

过滤发布文章的日期


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "1eb1c6a1b1d64fca20620178efd0ef14" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "da3fa25e51008d111052e4f7cd1619a4" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

datemore...

themore...


参数

$the_datestring|int
如果$format是'U'或'G',则格式化日期字符串或Unix时间戳。
$formatstring
PHP日期格式。
$postWP_Post
post对象。


源码

查看源码 官方文档


更新日志

版本描述
3.0.0开始引入

使用示例

  • 示例1

    从Codex迁移的示例:

    以下是如何使用get_the_date过滤器修改名为“product”的文章类型的日期格式的基本示例:

    add_action( 'get_the_date', 'my_project_filter_publish_dates', 10, 3 );
    
    function my_project_filter_publish_dates( $the_date, $d, $post ) {
    	if ( is_int( $post) ) {
    		$post_id = $post;
    	} else {
    		$post_id = $post->ID;
    	}
    
    	if ( 'product' != get_post_type( $post_id ) )
    		return $the_date;
    
    	return date( 'Y-d-m - h:j:s', strtotime( $the_date ) );
    }