Code to Add Dynamic Copyright Date in WordPress Footer

You can use this code to add a dynamic copyright date in WordPress footer .

function wpe_copyright() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
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;

After adding this function, you’ll need to open your footer.php file and add the following code wherever you like to display the dynamic copyright date:

<?php echo wpe_copyright(); ?>

This function looks for the date of your first post, and the date of your last post. It then echos the years wherever you call the function.