2024年10月19日 建站教程
wordpress文章显示发布时间或修改时间用代码如何实现,官网给出了the_time()和the_modified_time()两个代码,下面我们详细介绍一下!
1、显示发布时间
<?php the_time('Y年n月d日 H:i:s'); ?>
2、显示修改时间
<?php the_modified_time('Y年n月d日 H:i:s'); ?>
3、如果已修改发布修改时间否则显示发布时间
<p>发布于<?php the_time('Y年n月d日 H:i:s'); ?>
<?php if ((get_the_modified_time('Y')*365+get_the_modified_time('z')) >(get_the_time('Y')*365+get_the_time('z'))) { ?>
<?php echo ',最后一次修改于' ?><?php the_modified_time('Y年n月d日 H:i:s'); ?>
<?php } ?>
</p>
本文链接:http://so.lmcjl.com/news/15729/