How to Update the Year Automatically in Your WordPress Footer

How to Update the Year Automatically in Your WordPress Footer

If you have a WordPress website, you may have noticed that the copyright year in the footer doesn’t update automatically. This can be a hassle to manually update every year, especially if you have multiple websites to manage.

Fortunately, there is a simple solution to this problem: you can use a snippet of PHP code to automatically update the year in the WordPress footer. In this post, we’ll show you how to do it.

Prerequisites

Before we get started, there are a few things you’ll need:

  • A WordPress website with access to the source code
  • Basic knowledge of HTML and PHP

Step 1: Add this Javascript code to your website

The first step is to add the following Javascript code to your website.

var currentYear = new Date().getFullYear();
document.getElementById("year").innerHTML = currentYear;

This code uses JavaScript to get the current year and update the element with the ID “year” to display the current year.

There are a lot of different ways to add custom Javascript code to your website. If you need help doing that I recommend checking out our guide on how to add custom Javascript to your WordPress website.

Now that you’ve added the custom Javascript code to WordPress, you’ll need to add a snippet of HTML code to your footer. This code will show the current year automatically anywhere you place it on your website.

<span id="year"></span>

Depending on your theme, you may have different ways of updating your footer. But here’s some steps you can follow that should work on most WordPress themes:

  1. Log in to your WordPress dashboard and go to Appearance > Customize.
  2. From the Customizer menu, click on the Footer Settings option.
  3. Here, you should have the option to update your copyright text. Simply add the HTML code as shown below.
  4. Click the Publish button to save your changes.
© <span id="year"></span> YourWebsiteName. All Rights Reserved.

To make sure the code is working correctly, visit your website and check the footer to see if the copyright year has been updated to the current year. If it has, then the Javascript code is working as intended. If not, you may want to double-check the code and make sure it was added correctly.

Conclusion

Updating the copyright year in the WordPress footer can be a hassle, but it doesn’t have to be. By using a snippet of Javascript code, you can easily and automatically update the year to the current year. Just follow the steps outlined in this post and you’ll have a fully-automated footer in no time.

We hope this post has been helpful. If you have any questions or need further assistance, feel free to leave a comment below. You can also learn more about WordPress by checking out our articles here.

Total
0
Shares
Leave a Reply

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

Previous Post
How to Add Custom JavaScript to Your WordPress Website

How to Add Custom JavaScript to Your WordPress Website

Next Post
How to Disable SiteGround Security "Weekly Activity" Emails

How to Disable SiteGround Security “Weekly Activity” Emails

Related Posts