How to automatically display the year in Hestia's footer copyright text
Hestia's copyright portion of the Footer section can be updated manually from the Customizer as follows:
However, if you'd like to add a proper Copyright for your own personal brand and include the current year dynamically and automatically, without having to manually update the text every year, then this guide is for you.
In order to ensure that the year is automatically generated without needing to be updated every year, we can use a bit of JavaScript code. JavaScript will automatically get the current year through a request and add it to your site according to your preferences.
What do I need to do?
First of all, you need to install a new plugin called Header and Footer Scripts which will help us to add the code to your website.
After installing and activating this plugin, you will need to navigate to Settings -> Header and Footer Scripts and you should be able to notice 2 text fields:
In one of the text fields from the picture above (preferably in the Footer) add the following code:
<script type="text/javascript"> window.addEventListener('load', function(){ const copyright = document.querySelector('footer.footer div.hestia-bottom-footer-content div.copyright'); var year = new Date(); copyright.innerHTML = 'Copyright ' + year.getFullYear() + ' My Brand Name'; }); </script>
Save the changes and that's it!
What does the code do exactly, and how to customize it?
We hope this helps!