
每个网站底部都会出现一个版权日期,比如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版权日期
上面是“wordpress底部的版权日期如何实现每年自动更新”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4388.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

一款由网易出品模拟器软件——MuMu模拟器