Auto-updating copyright year in the footer
-
Hey guys,
Is there any simple way to add an auto-updating copyright year into the Laytheme’s text editor to read, ie. ”© 2020 Laytheme.com All rights reserved.”?
Thanks
-
-
@mariusjopen and @arminunruh
I know this is an old post, but I'm trying to do the same, however like this "© 2018—2023" in a Footer page.
I have a text box inside the footer with the following source code:<p>© 2018—<span id="currentYear"></span></p>
And i'm adding some custom JS in "Custom HTML at bottom":
<script> window.laytheme.on("newpageshown", function(){ jQuery("#currentYear").text((new Date).getFullYear() ); }); </script>
This is working perfectly on desktop, however I can't seem to make it work on mobile. It's just shows "© 2018—".
I already tried a few things but without success. Do you have any idea how to fix this?Here's the link if you want to check it —> https://aaltar.com/homepage-2023/
-
i think id's are meant to be unique maybe thats why it doesnt work
try
<p>© 2018—<span class="currentYear"></span></p>
both in your desktop layout and your custom phone layout
and then<script> window.laytheme.on("newpageshown", function(){ jQuery(".currentYear").text((new Date).getFullYear() ); }); </script>
-
@arminunruh I tried this, however, as soon as I change the source code of the text box to 'class' and click OK, the source code changes (automatically) to '<p>© 2018—</p>'. It completely removes the span tag if there's a class instead of an id...I don't know why.
Is there another solution for this?
-
i think id's are meant to be unique maybe thats why it doesnt work
try
HTML:
<p class="currentYear">test</p>
JS:
<script> window.laytheme.on("newpageshown", function(){ jQuery(".currentYear").text("© 2018—" + (new Date).getFullYear() ); }); </script>
-
@arminunruh I think it was because the span tag was empty. It works now!!
Thank you so much!
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it