Wordpress Dynamic Copyright Date


/ Published in: PHP
Save to your folder(s)

in the theme's footer.php insert


Copy this code and paste it in your HTML
  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. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.