我正在使用由名为Scott Wallick的人创建的WordPress博客主题。 Here是他的网站。仅供参考,我正在使用“Barthelme”主题。
无论如何,这个主题打印日期如下:2009年8月5日显示为“2009 08 05”。我想将显示更改为以下格式:2009年8月5日。
我该怎么做?
我在WordPress代码中找到了以下功能。我可以以某种方式改变下面的代码,让它做我上面提到的吗?如果是这样,我应该做出哪些改变?
function barthelme_date_classes($t, &$c, $p = '') {
$t = $t + (get_option('gmt_offset') * 3600);
$c[] = $p . 'y' . gmdate('Y', $t);
$c[] = $p . 'm' . gmdate('m', $t);
$c[] = $p . 'd' . gmdate('d', $t);
$c[] = $p . 'h' . gmdate('h', $t);
}
答案 0 :(得分:2)
尝试以下方法:
function barthelme_date_classes($t, &$c, $p = '') {
$t = $t + (get_option('gmt_offset') * 3600);
$c[] = $p . 'j' . gmdate('j', $t);
$c[] = $p . 'M' . gmdate('M', $t);
$c[] = $p . 'Y' . gmdate('Y', $t);
$c[] = $p . 'h' . gmdate('h', $t);
}
我刚刚更改了每个日期元素的存储顺序,并使用了您要求的格式。
答案 1 :(得分:0)
在Barthelme主题中,index.php的第23行读取
<span class="entry-date">
<abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>">
<?php unset($previousday); printf(__('%1$s', 'barthelme'), the_date('Y m d', false)) ?>
</abbr>
</span>
将其更改为
<span class="entry-date">
<abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO'); ?>">
<?php unset($previousday); printf(__('%1$s', 'barthelme'), the_date('j M Y', false)) ?>
</abbr>
</span>