Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Add a Dynamic Copyright Date in WordPress Footer

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Add a Dynamic Copyright Date in WordPress Footer

Often you will see a website that has an outdated copyright date which is pretty annoying. There are also sites that only show the current year for their copyright date which is even more annoying because you won’t know how old the site is. There is a simple PHP solution to this that most developers would know, but there is a more elegant way that we will show you. In this article, we will share a function that will automatically generate a copyright date based on the published date of your oldest and newest post.

Simple PHP Solution for Dynamic Copyright Date

You would paste something like this in your theme’s functions.php file

&copy; 2009 – <?php echo date('Y'); ?>

The problem with this issue is that you would have to add this once your site is at least one year old.

Elegant WordPress Solution for Dynamic Copyright Date

While surfing the web, we saw a more elegant solution suggested by @frumph of CompicPress Theme. They are using this function on their excellent ComicPress theme. This function will generate a dynamic copyright date based on the published date of your oldest post and your newest post. If it is the first year of your site, then this function will only display the current year.

To implement this dynamic copyright date in your WordPress footer, open your theme’s functions.php file and add the following code:

function comicpress_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 = "&copy; " . $copyright_dates[0]->firstdate;
if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
$copyright .= '-' . $copyright_dates[0]->lastdate;
$output = $copyright;
return $output;

Then open your theme’s footer.php file and add the following code where you want to display the date:

<?php echo comicpress_copyright(); ?>

This function will add the following text:

© 2009 – 2010

Don’t keep your copyright dates outdated. Take advantage of this technique in your current and future WordPress sites.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Mirco says:

    You can also try the Copyright Shortcodes plugin (it’s on the WordPress plugin directory).

    Available shortcodes are: [copyright year=YYYY], [copy], [year], [years by=YYYY list=true/false sep=“, “]


  2. Brandon Hann says:

    This is the code I used for a long time until I realized that the year is pulled based off of GMT, so if you don’t want users in different time zones to see your site’s year change early or late, don’t use this tag…change echo date to echo date_i18n

    For example, when I used the original code, I went to my website on Dec 31st, 2014 at around 6pm PST. My website was already showing the year 2015 because Pacific Standard Time is 8 hours behind GMT.

    With the date_i18n change, your site will show the current year based on the visitor’s timezone instead. For those that are curious, i18n is an abbreviation of “internationalization” because there are 18 letters between the ‘I’ and the ‘N’.

  3. hayward says:

    I am having trouble with adding the code to my function.php footer. Now I am getting this error message Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home3/hsp1990/public_html/wp-content/themes/couponpress/functions.php on line 35

    • Rex AZ says:

      You should use a child theme rather than working with your parent theme. Just go over to the wordpress codex and source for child theme development. Just create a new functions.php file and a footer.php file in your child theme directory and insert the codes. You are good to go.

  4. Chris says:

    how can I modify this code, so that I can have a fix “first date” of “1999”, instead of the date of the first published posting?

  5. menj says:

    I have used the code above, with a slight modification to the comicpress_copyright() function which I renamed to a more generic one.

  6. jrstaples1 says:

    Nice tip! I addded this with almost zero coding knowledge. How would I add my site title after the year?

  7. Ole says:

    Wow. This is great. Thank you

  8. Dominic says:

    Something like this might be easier and less intensive.

    $year = date('Y');
    if ($year != 2009){
    echo '© 2009 – '.$year.'';
    } else {
    echo '© 2009';

  9. Gary says:

    It’s worth pointing out that copyright exists for a number of years from the first time it was published. That means there’s to things to consider:

    1) The visual copyright notice is not necessary under the Berne treaty – it has no standing in law whether you have it on the site or not.

    2) If the site was first published in a certain year, claiming it could be actually published in a later year actually lowers any claim you may have for copyright infringement.

    Also, most visual copyright notices, for what they are worth, also need to put who the copyright is to, after the year(s).
    Finally, it’s typographically correct to use an “en dash” instead of the hyphen-minus character you’ve suggested.

    • Dave Hildebrand says:

      Surprised this hasn’t been added to every theme writers toolbox.

      I changed – to – and added in my name as per Gary’s comments.

  10. Maverick says:

    Little better way for this feature is to add php variable about site name (able to change in admin panel), for example:
    © 2009 –

  11. anggiaj says:

    Great tips, problem solved, thanx

  12. Zhu says:

    Thanks for the tip! I implemented that in about 60 seconds :-)

  13. Derek Jensen says:

    It surely does bug me when I go to a site and the copyright is out of date but yet they are publishing fresh content.

    This will be a nice dummy factor for that.

    As always I enjoy your guys as a WordPress resource.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.