Automatically Update Your Copyright Year with PHP
This tutorial is written for those of you who find yourself forgetting to update the year in your site's copyright line. I've seen some sites with copyright lines that are over five years outdated. Let's take a look at how you can set your site's footer to always display the current year in the copyright line.
Where do I find my copyright date in WordPress?
In most cases, you will find this in your theme's footer.php
file. If you are using a child theme (you should be), you will first want to look for the footer.php
file within your child theme's directory.
In the most recent WordPress default Twenty Seventeen theme, you will be editing /template-parts/footer/site-info.php
.
Once you have identified the proper file to edit, open it and look for the text from your footer's copyright line. In Twenty Seventeen as well as many other themes, this is found within a div with the class "site-info".
Now that we know where to make the changes, let's update it to display a dynamic copyright line.
How to display the current year in the copyright line using PHP
To get the current year in PHP we can use:
echo date("Y");
Keep in mind that this returns the date from the server.
Now you can get back to focusing on celebrating the new year instead of worrying about your copyright date!
No more updates needed — your footer copyright will always display the current year!