通过获取网站第一个注册的用户年份来判断网站的建立日期。
把以下代码放入function.php中即可。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
/显示网站运营版权时间 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(); ?>






最新评论
站长您好,亚马逊云咨询推广资源,望建立联系,可邮件,谢谢。
换友情链接吗?
看你的站做的挺不错的
恭喜!!太强了,硕博连读啊
雁过留毛,人过留名。
看不懂但大受震撼
每天都在战争,希望2026和平.
ZeroTier 看过多篇帖子,目前群辉、飞牛os、win11 、安卓、ubuntu ≥18.04 顺利通过,这篇相对于简单 实用、特来感谢 🙄