How to get current year shortcode on WordPress – JavaScript

How to get current year shortcode on WordPress – JavaScript

This is very important to show the current year on the footer for copyright purposes.
But sometimes we can’t do it because of the theme rules. Some WordPress themes have the permission to show the dynamic display of the current year on the footer only. If we edit the footer by using Elementor or we use the theme “current year” shortcode anywhere, it does not work.

If we use JavaScript then this will be solved.
Use the code on your WordPress backend and see the magic.

window.addEventListener('load', (
    function () {
                new Date().getFullYear()

In this case, “copyright-year” this is the CSS ID. you can use it with span tag that’s good actually.

See the example below:

Copyright <span id="copyright-year">©</span> Sefatun. All Rights Reserved.

Note: this plugin can help you add code in the head or body “Simple Custom CSS and JS“.

1 Comment

  1. İşiniz İçin En İyi Çözüm!: İşinizde mobil doğrulamaya ihtiyaç duyuyorsanız, endişelenmeyin! Mobil SMS Onay, hızlı ve güvenilir hizmetiyle size en uygun çözümü sunar. İşlerinizi kolaylaştırmak için şimdi başlayın.

Leave a Reply

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