Self updating (Dynamic) year

Colette Smith came up with this so don’t think I had anything to do with it. And if this page is found for whatever reason, do yourself a favour and connect with Colette and sign up to her newsletter.

Make any text a link and add #[yearDynamic] as the destination link. Then add this lot to the code-injection —> Footer section:

<!-- Dynamic Year in Footer - Courtesy of Colette Smith -->
<style>
  footer a[href="#[yearDynamic]"] {
    background: transparent !important;
    text-decoration: none;
    pointer-events: none !important;
    color: inherit !important;
  }
</style>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    var dynamicYear = document.querySelector('footer a[href="#[yearDynamic]"]');
    if (dynamicYear) {
      dynamicYear.textContent = new Date().getFullYear();
    }
  });
</script>
<!-- End of Dynamic Year in Footer -->

E.g. Here is the text and set up:

 

An alternative - add a code block and add this, changing what you need to personalise it:

<p>&copy; THAT Branding Company <script>document.write(new Date().getFullYear())</script>. All Rights Reserved.</p>

THAT Branding Company

A Creative Branding and Design Agency with one clear goal - making your business a success. Get in touch - 0191 8100 320.

http://www.thatbranding.company
Previous
Previous

ALL CODE, ALL SITES

Next
Next

Rotating image