如何更改WordPress中日期的显示方式

时间:2017-09-10 10:43:37

标签: php wordpress

我想永久删除日期中的日期和月份,但保留年份。这适用于运行文化主题的WordPress 4.8.1。

换句话说;当我以后编写和发布帖子时,只有YEAR会显示在博客页面(首页)和单个帖子视图上。

关于如何解决这个问题的任何想法?

1 个答案:

答案 0 :(得分:0)

您可以使用以下功能并根据您的要求进行修改

function my_project_filter_publish_dates( $the_date, $d, $post ) {
return date( 'Y', strtotime( $the_date ) );
}
add_filter( 'get_the_date', 'my_project_filter_publish_dates', 10, 3 );