Okay
  Public Ticket #2822242
Adding dynamic year to footer widget
Closed

Comments

  •  23
    alberteck started the conversation

    Hi guys

    To add a dynamic footer year in Salient, we need to use the default footer. In case disable the default footer and we use a widget for the copyright tag, we'd have to use a static year for copyright.

    A way around would be to add a php snippet into the functions.php file and then call that function using HTML in the footer widget.

    I was wondering, since you guys already have dynamic footer defined somewhere, how can we pull the dynamic year from what's already been defined, instead of making any modifications to the functions.php file or without installing additional plugins?

    Thanks!

  •  1,882
    Judith replied

    Hi Alberteck,

    Please try adding this on the widget:

    © {YEAR} {SITENAME}

    Thanks.

  •   alberteck replied privately
  •  23
    alberteck replied

    Hi

    I just tried that

    Doesn't seem to work

  •  1,882
  •  23
    alberteck replied

    Tried that. The disadvantage with that is: We have to modify the functions.php file, which means every time we update the theme, that snippet would vanish.

    An alterative to that would be to have Code Snippets or another plugin like that since Salient doesn't have an inbuilt custom php section, but that would be adding another plugin, and hence more load, in turn worse performance of the website.

    For anyone else interested, here's the solution I've found, and it uses HTML5 and JS alone: <script>document.write( new Date().getFullYear() );</script>

    This solution still adds a script and get request, so it will impact load speeds, but it hopefully will be negligible.

  •  1,882
    Judith replied

    Hi Alberteck,

    Thanks for sharing the solution. I truly appreciate.

    Kind Regards.