footer的自动版权信息部分

Posted by Y Cheung on Thu, Dec 10, 2009

PHP代码:

 1<?php global $wpdb; 
 2$post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970")); 
 3
 4if ($post_datetimes) { 
 5    $firstpost_year = $post_datetimes->firstyear; 
 6    $lastpost_year = $post_datetimes->lastyear; 
 7    $copyright = $firstpost_year; 
 8    if($firstpost_year != $lastpost_year) { 
 9        $copyright .= '-'. $lastpost_year; 
10        } 
11    $copyright .= ' '; 
12    echo $copyright; 
13    } ?>
14    < ?php bloginfo('name'); ?><?php echo get_option('home'); ?> / Theme designed by 你的大名

CSS代码:

1 #copyright { float:left; display:inline; margin:55px 0 0 -10px; color:#777; } #copyright li { float:left; display:inline; font-size:11px; margin:0 10px 0 0; padding:0 0 0 13px; background:url(img/footer_line.gif) no-repeat left center; } #copyright li a, #copyright li a:visited { text-decoration:underline; }