通过获取网站第一个注册的用户年份来判断网站的建立日期。
把以下代码放入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(); ?>
进来学习
大佬 你这个百度收录查询是怎么弄的?
真的不错
加油
有点麻烦
师兄,我昨天向你请教容器内存满的问题
不错
好好学习