Posted By

xavsio4 on 07/06/11


Tagged

wordpress functions


Versions (?)

Wordpress Dynamic Copyright Date


 / Published in: PHP
 

in the theme's footer.php insert <?php>

  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 = "&copy; " . $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. }

Report this snippet  

You need to login to post a comment.