function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('Y年m月d日 G:i:s');
$custom_content .= '<p>本文最后更新于:'. $updated_date . '</p>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );
以上代码需要添加到 functions.php
<?php
function wpb_last_updated_date( $content ) {
$u_time = get_the_time('U');
$u_modified_time = get_the_modified_time('U');
if ($u_modified_time >= $u_time + 86400) {
$updated_date = get_the_modified_time('Y年m月d日 G:i:s');
$custom_content .= '<div class="wp-block-zibllblock-alert alert-dismissible fade in"><div class="alert jb-blue">最近更新:'. $updated_date . '</div></div>';
}
$custom_content .= $content;
return $custom_content;
}
add_filter( 'the_content', 'wpb_last_updated_date' );
子比主题为了防止更新后失效 请在目录内新建func.php 文件 插入上方代码即可