免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2140 | 回复: 1
打印 上一主题 下一主题

wordpress页脚添加动态的版权日期 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-30 11:25 |只看该作者 |倒序浏览
wordpress页脚添加动态的版权日期









页脚的版权信息和日期是很常见的  也是任何网站必有的模块
wordpress中对此有特殊的函数处理 如果想加入动态的又比较合规范的页脚版权日期

1 简单方法:推荐
在你的footer文件中加入如下代码
  1. &copy; 2011 – <?php echo date('Y'); ?> YourSite.com
复制代码
2 合乎规范的高质量的动态添加方式 (强烈推荐):



Java代码
  1. 1.function comicpress_copyright() {   
  2. 2.global $wpdb;   
  3. 3.$copyright_dates = $wpdb->get_results("   
  4. 4.SELECT   
  5. 5.YEAR(min(post_date_gmt)) AS firstdate,   
  6. 6.YEAR(max(post_date_gmt)) AS lastdate   
  7. 7.FROM   
  8. 8.$wpdb->posts   
  9. 9.WHERE   
  10. 10.post_status = 'publish'  
  11. 11.");   
  12. 12.$output = '';   
  13. 13.if($copyright_dates) {   
  14. 14.$copyright = "&copy; " . $copyright_dates[0]->firstdate;   
  15. 15.if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {   
  16. 16.$copyright .= '-' . $copyright_dates[0]->lastdate;   
  17. 17.}   
  18. 18.$output = $copyright;   
  19. 19.}   
  20. 20.return $output;   
  21. 21.}  
  22. function comicpress_copyright() {
  23. global $wpdb;
  24. $copyright_dates = $wpdb->get_results("
  25. SELECT
  26. YEAR(min(post_date_gmt)) AS firstdate,
  27. YEAR(max(post_date_gmt)) AS lastdate
  28. FROM
  29. $wpdb->posts
  30. WHERE
  31. post_status = 'publish'
  32. ");
  33. $output = '';
  34. if($copyright_dates) {
  35. $copyright = "&copy; " . $copyright_dates[0]->firstdate;
  36. if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
  37. $copyright .= '-' . $copyright_dates[0]->lastdate;
  38. }
  39. $output = $copyright;
  40. }
  41. return $output;
  42. }
复制代码
在footer.php中添加如下代码

  1. <?php echo comicpress_copyright(); ?>
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-12-30 22:09 |只看该作者
学习鸟谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP