Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将wordpress中的日期格式更改为相对日期_Php_Wordpress - Fatal编程技术网

Php 将wordpress中的日期格式更改为相对日期

Php 将wordpress中的日期格式更改为相对日期,php,wordpress,Php,Wordpress,这里需要一些帮助,因为我对PHP不太熟悉。我有两种帖子类型,一种是显示x时间前格式的日期,另一种是显示传统的wordpress日期格式 我在我的wordpress主题中发现了这一行,它在我的文章中显示了传统的格式 $postheader .= '<abbr class="published" title="' . get_the_time('c') . '">' . get_the_time( get_option('date_format') ) . '</abbr>&

这里需要一些帮助,因为我对PHP不太熟悉。我有两种帖子类型,一种是显示x时间前格式的日期,另一种是显示传统的wordpress日期格式

我在我的wordpress主题中发现了这一行,它在我的文章中显示了传统的格式

$postheader .= '<abbr class="published" title="' . get_the_time('c') . '">' . get_the_time( get_option('date_format') ) . '</abbr></span>';
现在,这个主题已经有了一个预先编写的函数,可以显示定义为“%s”的x分钟、天、周、年前的时间,下面的代码中使用了这个函数

<abbr class="published" title="<?php the_time('c') ?>"><?php printf( __('%s', 'arras'), arras_posted_on( false ) ) ?></abbr> | <a href="<?php comments_link() ?>"><?php comments_number() ?></a>
我的问题是。。如何修改第一个代码以显示x时间之前的格式,就像第二个代码中使用的格式一样?我试图粘贴完全相同的行,它使我的页面在重新加载时变为空白

尝试使用以下代码:

$postheader .= '<abbr class="published" title="' . arras_posted_on( false ) . '">' . arras_posted_on( false ) . '</abbr></span>';

检查服务器日志。任何分析错误都会显示在那里,这将帮助您调试代码。