Typically you will notice an internet site that has an outdated copyright date which is fairly annoying. There are additionally websites that solely present the present 12 months for his or her copyright date which is much more annoying since you received’t understand how previous the location is. There's a easy PHP answer to this that the majority builders would know, however there's a extra elegant method that we are going to present you. On this article, we are going to share a operate that can mechanically generate a copyright date primarily based on the revealed date of your oldest and latest submit.
Easy PHP Resolution for Dynamic Copyright Date
You'd paste one thing like this in your theme’s features.php file
© 2009 – <?php echo date('Y'); ?> YourSite.com
The issue with this problem is that you would need to add this as soon as your website is no less than one 12 months previous.
Elegant WordPress Resolution for Dynamic Copyright Date
Whereas browsing the net, we noticed a extra elegant answer prompt by @frumph of CompicPress Theme. They're utilizing this operate on their glorious ComicPress theme. This operate will generate a dynamic copyright date primarily based on the revealed date of your oldest submit and your latest submit. If it's the first 12 months of your website, then this operate will solely show the present 12 months.
To implement this dynamic copyright date in your WordPress footer, open your theme’s features.php file and add the next code:
operate comicpress_copyright()
Then open your theme’s footer.php file and add the next code the place you need to show the date:
<?php echo comicpress_copyright(); ?>
This operate will add the next textual content:
© 2009 – 2016
Don’t hold your copyright dates outdated. Benefit from this method in your present and future WordPress websites.