2009-08-29 106 views
2

我使用由名为Scott Wallick的人创建的WordPress博客主题。 Here是他的网站。仅供参考,我正在使用“Barthelme”主题。WordPress博客日期功能

无论如何,这个主题打印日期如下: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); 
} 

回答

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); 
} 

我只是改变了每一个日期元素存储的顺序,并使用你要求的格式。的index.php

+0

我想这并没有改变任何东西...任何其他的想法?谢谢。 – John 2009-09-03 00:04:00

0

在巴塞尔姆主题,第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>