How to Add a Self-Editing Copyright Date to Your WordPress Theme
Copyright is a tricky issue – but no matter what copyright your blog uses, the date is more than likely wrong – so how do you fix it?
You can edit the theme by hand every year to insert the new date – 2002-2009, 2002-2010, etc – or you can use a little PHP to handle it.
In your theme, find the copyright year, which is probably in footer.php. It often looks something like this:
Copyright © 2007 by Somebody or other...
What you want to do is change it to this:
Copyright © 2007-<?php echo date('Y'); ?> by Somebody or other...
The PHP date() function outputs the current time, formatted the way you want – in this case, the ‘Y’ prints out a 4-digit year.
Of course, if you started your blog (and copyright) in 2009, then you’ll get this displayed:
Copyright © 2009-2009
Which looks twonky – so here’s how you can fix that with a little extra PHP:
Copyright © <?php $a=2009; $z=date('Y'); echo ($a==$z?$a:"$a-$z"); ?> by Somebody or other...
This little bit of code simply checks if the start year matches the current year – if so, just one year is output. If not, a range is displayed. You’ll have to edit the 2009 to point to YOUR start year – but then that’s the last edit you’ll ever have to do for the Copyright on this theme!









Leave your response!