- 论坛徽章:
- 0
|
wordpress页脚添加动态的版权日期
页脚的版权信息和日期是很常见的 也是任何网站必有的模块
wordpress中对此有特殊的函数处理 如果想加入动态的又比较合规范的页脚版权日期
1 简单方法:推荐
在你的footer文件中加入如下代码- © 2011 – <?php echo date('Y'); ?> YourSite.com
复制代码 2 合乎规范的高质量的动态添加方式 (强烈推荐):
Java代码- 1.function comicpress_copyright() {
- 2.global $wpdb;
- 3.$copyright_dates = $wpdb->get_results("
- 4.SELECT
- 5.YEAR(min(post_date_gmt)) AS firstdate,
- 6.YEAR(max(post_date_gmt)) AS lastdate
- 7.FROM
- 8.$wpdb->posts
- 9.WHERE
- 10.post_status = 'publish'
- 11.");
- 12.$output = '';
- 13.if($copyright_dates) {
- 14.$copyright = "© " . $copyright_dates[0]->firstdate;
- 15.if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
- 16.$copyright .= '-' . $copyright_dates[0]->lastdate;
- 17.}
- 18.$output = $copyright;
- 19.}
- 20.return $output;
- 21.}
- function comicpress_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;
- }
复制代码 在footer.php中添加如下代码
- <?php echo comicpress_copyright(); ?>
复制代码 |
|