web建站教程
     
  1. 首页
  2. 前端UI组件库
  3. AI项目和框架
  4. AIGC工具
  5. 百度echarts
  6. 地图大全
  7. 前端知识
  8. 更多
    vuejs
    js入门
    php入门
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站
    AI应用

wordpress底部的版权日期如何实现每年自动更新

1061 ℃

每个网站底部都会出现一个版权日期,比如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做时间列表,比如2024年1月文章列表

wordpress利用mysql获取指定分类下的文章

WordPress如何重置admin密码

WordPress教程如何自动删除文章中图片宽高样式

wordpress建站如何快速提交和优化您的网站(IndexNow插件)?

标签: wordpress技巧 wordpress版权日期

上面是“wordpress底部的版权日期如何实现每年自动更新”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_4388.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 首页 > wordpress
Trae:新一代免费的AI编程工具

在线育儿补贴计算器

快来看看你到底可以领到多少补贴!生活小工具
上一篇:
下一篇:
x 打工人ai神器