Codeable info

How To Automatically Update Your Copyright Notice

Posted on by in WordPress Tutorials

Copyright notices are a common feature on many website footers. As we crawl into 2012, you will need to remember to update your own copyright notice so that it isn’t out of date. John Chow reminded me how easy it is to make sure your copyright notice is updated automatically every year.

To display the current year on your website you need to use the_date function.

<?php echo the_date('Y'); ?>

So to add a copyright notice to your footer we just need to add something like this to your footer.php template:

Copyright &copy; <?php echo the_date('Y'); ?> Website Name

You can easily extend this further if you want to include the year your website launched:

Copyright &copy; 2010 - <?php echo the_date('Y'); ?> Website Name

If you have a copyright notice in your website footer, I encourage you to add automate it so that it is updated automatically every year.

Good luck :)

Kevin

)
Codeable info

Comments (11)

Comment by kshort5 says:

I love it, nice and simple. It didn’t work for me until I did this:
Copyright © 2010 – <?php echo the_date(‘Y’); ?> templatz.co
 
I took out the “the_” before date and it worked perfect.
Before that I was getting some error message.
 
Anyway I thought this might help someone and thanks for the code.
 
Oh! BTW using this code gave me:
Copyright © 2010 – 2012 templatz.co/All Rights Reserved.

Comment by Kevin Muldoon says:

Looks like a handy function. Thanks for the link :)

Comment by Damian Gostomski says:

I’ve written a short snippet which is an improvement over this, as it supports date ranges, so all you enter is the start date, and then it will display it as just that year, or that year to the current one if applicable

Check it out at http://www.gostomski.co.uk/snippet/better-auto-updating-copyright-date

Comment by Kevin Muldoon says:

No problem. If you do want to add it, feel free to post the code in the forums and I’ll have a look at it :)

Comment by Andy says:

cheers, but cannot get it right, so just added it manually, and put it in my diary for updating next dec 31st :) no worries.

Comment by Kevin Muldoon says:

Ahh yes. Some problems arise when the function is used twice on a page.

SPECIAL NOTE: When there are multiple posts on a page published under the SAME DAY, the_date() only displays the date for the first post (that is, the first instance of the_date()). To repeat the date for posts published under the same day, you should use the Template Tag the_time() or get_the_date() (since 3.0) with a date-specific format string.
Use < ?php the_time(get_option('date_format')); ?> to add the date set in the admin interface.

If that’s the case, you can use the_time() function.

Comment by Andy says:

how does wp differentiate between the year a post was written and today’s Year?

The thing is it looks like the-time(Y) in the footer displays the-date(Y) in the single.php where I display the date the post was written.

the-date(Y) doesnt display in the footer, period

Comment by Kevin Muldoon says:

The function pulls the date from your server so if your server date is incorrect it will be reflected in the date that is displayed.

Comment by Andy says:

Your code is spot on but i think there is a quirk with some background date setting or the cache on my site, because the footer code with either the-time or the-date is now showing 2011. It was definitely -2012 yesterday:)

Comment by Kevin Muldoon says:

I tested this myself and it works perfectly. Are you sure you copied the code correctly?

Comment by Andy says:

i found that the-date didnt work, but the-time did. got the copyright update working though, so cheers for the impetus

Codeable info