How to Add a Dynamic Copyright Date in WordPress Footer

How to Add a Dynamic Copyright Date in WordPress Footer

Often you will see a website that has an outdated copyright date which is pretty annoying. There are also sites that only show the current year for their copyright date which is even more annoying because you won’t know how old the site is. There is a simple PHP solution to this that most developers would know, but there is a more elegant way that we will show you. In this article, we will share a function that will automatically generate a copyright date based on the published date of your oldest and newest post.

For this method, you’ll need to add some code to your WordPress theme files. If you haven’t done this before then checkout our guide on how to copy and paste code in WordPress.

The most common way to display a dynamic copyright date is by editing your WordPress theme’s footer.php file. Simply copy and paste the following code at the line where you want to display the copyright notice.

The problem with this code is that it cannot dynamically fetch your site’s start date and your site has to be at least an year-old before you can use it.

While surfing the web, we saw a more elegant solution suggested by @frumph of CompicPress Theme.

This code will generate a dynamic copyright date based on the published date of your oldest post and your newest post. If it is the first year of your site, then this function will only display the current year.

To add this, first you need to add the following code to your theme’s functions.php file or a site-specific plugin.

After that, you need to add the following code to your theme’s footer.php file where you want to display the date:

This function will add the following text:

Don’t keep your copyright dates outdated. Take advantage of this technique in your current and future WordPress sites.

Loading...

End of content

No more pages to load

Images Powered by Shutterstock