通过获取网站第一个注册的用户年份来判断网站的建立日期。
把以下代码放入function.php中即可。
/显示网站运营版权时间 by Daniel Ting
function auto_copyright(){
global $wpdb;
$first = $wpdb->get_results("
SELECT user_registered
FROM $wpdb->users
ORDER BY ID ASC
LIMIT 0,1
");
$output = '';
$current = date(Y);
if ($first) {
$first = date(Y, strtotime($first[0]->user_registered));
$copyright = "© " . $first;
if ($first != $current) {
$copyright .= '-' . $current;
}
$output = $copyright;
}
echo $output;
}
然后,在需要使用的地方放入引用即可:
<?php auto_copyright(); ?>
本文最后更新于2020年6月22日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!