本文最后更新于 1208 天前,文中的信息可能已经有所变化。如有误,请留言反馈。
文章有更新时会有提示,对于修改一些发布比较久的文章比较有用,可以提示用户此文章更新过了,按需添加。
- 将以下代码添加入正在使用的主题functions.php文件当中:
function is_modified(){
global $post;
$punish_time = get_the_date('U');
$modified_time = get_the_modified_date('U');
$timetime = time();
if( ( $modified_time > $punish_time) && ( $time - $modified_time < 3600*24*7 ) )
return true;
}
- 调用代码,将以下代码添加到想显示内容的地方:
<?php if( is_modified() ) : ?> 本文内容有更新 <?php endif;?>
*可根据使用情况更改代码。