Beginner's Guide for WordPress / Start your WordPress Blog in minutes

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

For this method, you’ll need to add some code to your WordPress theme files. If you haven’t done this before then checkout our guide on how to copy and paste code in WordPress.

The most common way to display a dynamic copyright date is by editing your WordPress theme’s footer.php file. Simply copy and paste the following code at the line where you want to display the copyright notice.

<p>&copy; 2020 – <?php echo date('Y'); ?></p>

The problem with this code is that it cannot dynamically fetch your site’s start date and your site has to be at least an year-old before you can use it.

Elegant WordPress Solution for Dynamic Copyright Date

While surfing the web, we saw a more elegant solution suggested by @frumph of CompicPress Theme.

This code 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 add this, first you need to add the following code to your theme’s functions.php file or a site-specific plugin.

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;

After that, you need to add the following code to your theme’s footer.php file where you want to display the date:

<?php echo comicpress_copyright(); ?>

This function will add the following text:

© 2009 – 2021

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

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

47 CommentsLeave a Reply

  1. I tried to do this as recommended in I pasted the code as a snippet in the Code snippet plugin. But I’m not sure what to do next: “add the following code to your theme’s footer.php file where you want to display the date: ”
    I guess I don’t understand how the Code snippet plugin works: where the code is added / how do I address ‘footer.php’>? I tried to just paste the code in the footer, but that didn’t work… Please help this coding-newbie?

  2. I think we should not waste time reinventing the wheel our self, instead utilizing the available plugins like Automatic Copyrights Shortcode.

    What you think?

    • That plugin was not available when this post was created, we will certainly take a look at it


  3. I gave this a try and, for a moment, it appeared to work.

    Clearing the WP cache and reloading the page resulted in the same old “Blah … blah … blah … | Proudly powered by WordPress” footer.

    I no longer see this code snippet in the functions.php file for the ComicPress theme.

    Does it matter WHERE in the functions.php and footer.php files the code snippets are added? If so, it would be a great help to know that.


  4. Does it have to be a child theme for this to stay in place? I’m on Twenty Seventeen, with no child theme. Do I need to worry about this being overwritten every time I get a WP udpate?

    Appreciate the help so much!

    • You can put the current year by just calling the php date() function with a ‘Y’.

      echo date(‘Y’);

  5. Could someone assist with information on how to add a text after the year? Where in the code should this be placed?

  6. After i clicked save on the functions.php. I’m facing a white-screen of death. I also dowloaded the functions.php file but couldn’t find your code there. How do i solve it?

  7. I need to change ” Last updated on January 5th, 2016 by Editorial Staff ” this date with current date…

    So which command I have to use…. I had tried this one…

    But I’m getting the same date…

  8. Thanks! this is great, i used it on my website
    I added a post for 1 year ago, like 2015 to have more than 1 year. then I realized I could simply write down 2015 in code lol..
    anyway i hope you laughed..

  9. This is WordPress Beginner!!! Why Don’t You tell the guys where exactly to put the code on PHP file? See lots of people breaking their websites so I would rather not try.

  10. I added the code to functions, and it completely wiped out my website. Blank screen – when i go to login page and when i simply type in my website URL. what happened? did exactly what was said tot do above :/

  11. Great share,
    thanks a lot. I have searched so long how to remove the copyright in wordpress.

    Greets Christina

  12. I have spent hours over several days trying to find the answer to the following need:

    A blogger’s copyright info is included automatically with each post. The blogger got married and changed her last name. How to get WordPress to use old name in copyright line for posts before wedding date and new name in copyright line for posts after the wedding date?

    I know get_the_date is key, but I don’t know how to write a conditional statement that says if post publication date is before October 1 2009, display maiden name, else display married name.

    (Or, of course, if post publication date is after wedding date, display married name.)

    I’m hoping one of you here will help me with this. Please?

  13. Hi, I tried to update the functions.php file, but instead I received 500 Error. What shall I do? It does not allow me to access my wordpress account to edit it back…. can you please help me?

  14. 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=“, “]


  15. 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’.

  16. 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

    • 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.

  17. Hi,
    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?

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

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

  20. Something like this might be easier and less intensive.

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

  21. 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.

  22. 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.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.