获取博文最后编辑的时间,展示在日志的末尾,让渎职来分辨这些信息是否还能正常使用。
- 原文来源:失效
百度了一下,原来 the_modified_time() 这个函数就是显示最后更新时间用的。
简单调用
调用的函数为:<?php the_modified_time('Y年n月j日'); ?>
其中的Y年n月j日可以自定义,比如改成Y-m-j或者Y-m-j h:s。
这串代码一般放在single.php中的内容循环下,例如函数:
<?php the_content(); ?>
之后
高级调用
上边的标签太单一,最好能做个判断,如果文章修改过(不包括当天),则显示最后一次修改时间,没修改或者当天修改过,则显示发布日期,代码为:
<?php if ((get_the_modified_time('Y')*365+get_the_modified_time('z')) > (get_the_time('Y')*365+get_the_time('z'))) : ?>最后修改:
<?php the_modified_time('Y-m-j h:s'); ?>
<?php else : ?>
<?php the_date_xml(); ?>
<?php endif; ?>
注意<?php the_date_xml(); ?>
是文章页模版的时间标签,如果在首页就需要修改成首页的。
关于wordpress的日期,这里有相关介绍: