WordPress: Show the current year on the footer

To show a copyright message with the current year on the footer, that automatically updates with the current year, use the [year] shortcode:

Copyleft © [year] LearnWithDaniel.com

Then, on functions.php (Appearance > Theme Editor > Theme Functions), add this code:

That’s it!

Alternative: Use JS to get the year:

Alternatively, you can implement it with JS only. No need to change functions.php:

Copyleft © <span class=”year”></span> LearnWithDaniel.com

Then add this JS (through a Custom HTML Widget, or on the theme customization “Appearance > Customize”, or through a plugin like “Custom CSS & JS”):

The problem with this solution is that it uses the user’s clock. If the user’s clock is set to 5 years ago, it will show “2016” instead of “2021” for example (considering we are in 2021).

An over-engineered solution: Shortcode with a JS callback

Use the shortcode [year] and this on functions.php:

Close Menu