如何在Wordpress中自定义日期格式 [英] How to customize Date Format in Wordpress

查看:128
本文介绍了如何在Wordpress中自定义日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Wordpress中自定义日期格式。我知道可以从Dashboard<<<<<设置<<一般<<日期。但是我的需求没有实现。

I need to customize the date format in Wordpress. I know that minor date changes can be made from Dashboard << Settings << General << Date. But my needs are not fulfilled from that.

我需要在帖子页面上,月份应该有不同的字体样式,而日期则有不同的字体。

I need that on post page, Month should have different font style and Day with a different font.

推荐答案

如果我正确理解你的问题,一个解决方案是将日期的每个部分包装在不同的span类中。因此,无论何时您想插入日期,您都会使用以下内容:

If I'm understanding your question correctly, one solution would be to wrap each part of the date in a different span class. So whenever you want to insert the date you would use something like the following:

<?php the_time('F', '<span class="month">', '</span>'); ?>
&nbsp;
<?php the_time('d', '<span class="day">', '</span>'); ?>

然后你可以在css中单独定位这些不同的span类。

Then you can target these different span classes separately in your css.

.month {
    font-family:serif;
}
.day {
    font-family:sans-serif;
}

这将输出如下格式: 4月11日可以根据需要单独设置月份和日期的样式。您可以通过更改传递到 the_time()函数的内容来显示不同的月/日期格式。例如,将月份代码更改为<?php the_time('m','< span class =month>','< / span>'); ?> 将输出 4月11日

This will output a format that looks like this: April 11 where both the month and date can be styled separately however you want. You can display a different month/date format by changing what you pass into the_time() function. For example, changing the month code to <?php the_time('m', '<span class="month">', '</span>'); ?> will output Apr 11 instead.

这有很多不同的配置,还有更多有关的信息 http://codex.wordpress.org/Formatting_Date_and_Time

There are a lot of different configurations for this and there's more info on that here http://codex.wordpress.org/Formatting_Date_and_Time

这篇关于如何在Wordpress中自定义日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆