Automatic Copyright Date in Footer (WP)

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; } //Next, you need to add this to your footer.php file where you would like to display the copyright date <?php echo comicpress_copyright(); ?>
So many sites have outdated copyright information while others show just the current year as their copyright date.

Display your correct copyright date (e.g. © 2005-2014) with this code to your functions.php file by looking for the date of your first post, and the date of your last post.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.