每个网站底部都会出现一个版权日期,比如web建站建站的版权日期是Copyright©2019-2023
,那么如何实现每年自动更新呢?
找到当前主题函数模板functions.php中新增以下代码:
function ipkd_copyright() { global $wpdb; $copyright_dates = $wpdb->get_results("SELECT YEAR(min(post_date_gmt)) AS firstdate, YEAR(max(post_date_gmt)) AS lastdate FROM $wpdb->posts WHERE post_status = 'publish'"); $output = ''; if( $copyright_dates ) { $copyright = "© " . $copyright_dates[0]->firstdate; if( $copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate ) { $copyright .= '-' . $copyright_dates[0]->lastdate; } $output = $copyright; } return $output; }
在页面中调用一以下代码:
<?php echo ipkd_copyright(); ?>
wordpress建站如何快速提交和优化您的网站(IndexNow插件)?
上面是“wordpress底部的版权日期如何实现每年自动更新”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4388.html
workflows工作流
一个穿着发光红色长袍的人
梦幻中的一只猫咪ComfyUI工作流
一个全脸彩绘和纹身的超级名模ComfyUI工作流
一个可爱的口袋妖怪ComfyUI工作流
奋斗的小黄人ComfyUI工作流
一位老人安详地坐在云层中钓鱼
一个黄色的海绵宝宝ComfyUI工作流
瀑布边坐着一位披着斗篷的隐士
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!