, , , ,

Automatically Update Your Copyright Year with PHP

Copyright Year with PHP

This instructional exercise is composed for those of you who end up neglecting to refresh the year in your site’s copyright line. I’ve seen a few destinations with copyright lines that are more than five years obsolete. We should investigate how you can set your site’s footer to dependably show the present year in the copyright line.

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 file within your child theme footer.php‘s directory.

In the most recent WordPress default Twenty Seventeen theme, you will be editing. /template-parts/footer/site-info.php

twenty-seventeen-copyright-footer

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

twenty-seventeen-copyright-footer-02

Now that we know where to make the changes, let’s update it to display a dynamic copyright line.

To get the current year in PHP we can use:

echo date(“Y”);

Keep in mind that this returns the date from the server.

twenty-seventeen-copyright-footer-03

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!

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *