How the year is automatically updated on your website (e.g. in the footer ©)

Category(ies): Wordpress
Published on 3.01.2023
Web Designer

What you can expect in this article:

Put an end to the annual routine of updating the year (e.g. in the copyright, but also possible everywhere else) in the new year. I'll show you a very simple trick to keep the year up-to-date automatically.
Christian Strasser Webdesigner

About the author:

Christian is a web designer & developer with over 8 years of experience in WordPress and web development. He develops conversion-optimized websites & online stores that perfectly combine design and function to make companies successful online. In addition to his work, he travels around the world and is inspired by new impressions.

Automatically update the year (e.g. in © Copyright in the footer)

Tired of manually changing the dates on your website every year? Then I've got just the thing for you. 

With a simple 4 lines of PHP code, WordPress automatically sets the current year. Provided that your server's time is set correctly. However, I would assume that this is the case.

1a. Add this code to your functions.php (my recommendation!)

The best way to do this is to use a Child themewhich I have described in more detail in this blog post.

// COPYRIGHT YEAR AS SHORTCODE //
function year_shortcode() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'year_shortcode');

1b. Insert this code with the plugin code snippet

If you are not so familiar with the WordPres folder structure and PHP, you can also implement this code risk-free via code snippets. However, I strongly recommend that you implement it using method 1a in the child theme. Nevertheless, I would like to show you a possible alternative.

To do this, install the plugin Code Snippets and create a new snippet with the above code. 

Convert year into code snippets

Practical The great thing about the plugin is that you cannot "destroy" your site with it. The plugin checks whether it causes an error when the code is activated. If so, the code will not be activated.

2. insert year in square brackets as the year

Then you just have to insert the shortcode "year" in the square brackets, which reads out the year of the server time or date, into the text instead of the manual year.

Enter the correct year in the copyright

The result: The year is now updated automatically

© 2025 CS Webdesigns | Imprint | Privacy Policy

The cool thing about this post is that it doesn't matter when you read it, it will always show the current year 😉 

Conclusion

With just four lines of code, you can save yourself an annoying annual ritual - especially if you maintain several websites. I recommend you implement it with variant 1a. If you are not yet using a child theme, take a look at my Blog post for this. This is also very easy and quick to do.

Comments

0 Comments

Submit a Comment

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

en_USEN
Christian Strasser

Christian Strasser

On working days I reply within a few hours.

On working days I usually reply within a few hours.

Christian Strasser
Hi 👋 
please leave me a message.

I will get back to you as soon as possible.

Best regards,
Christian
Whatsapp

Data protection consent