2013-05-03 121 views
1

需要一些帮助,因为我对PHP并不熟悉。我有两个帖子类型,一个以“x时间前”格式显示日期,一个显示传统的WordPress日期格式。将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时间前”的格式,就像第二个代码中使用的格式一样?我尝试粘贴完全相同的行,并且使得我的页面在重新加载时变为空白。

+0

检查服务器日志。任何解析错误都会显示在那里,并会帮助您调试代码。 – Jared 2013-05-03 06:00:58

回答

0

尝试使用此代码:

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

谢谢!改变了代码,它的工作就像一个魅力。 – 2013-05-03 09:31:34