How to Automate your WordPress Site’s Copyright Dates.

I have been going through my numerous sites gasping at all of the footer copyrights that still say “2008” and are also annoying me that they don’t show my first date of copyright. Well, don’t let it happen to you next year. Plug this into your footer template and make a copy of the code in a text file in case you switch themes before next year:

get_results("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970");
			if ($post_datetimes) {
				$firstpost_year = $post_datetimes[0]->firstyear;
				$lastpost_year = $post_datetimes[0]->lastyear;

				$copyright = __('Copyright © ', 'jesse') . $firstpost_year;
				if($firstpost_year != $lastpost_year) {
					$copyright .= '-'. $lastpost_year;
				$copyright .= ' ';

				echo $copyright;