Add java script to footer (child theme)

  • Author
    Posts
  • #69028
    nextstep
    Power User

    I would like to add a small piece of java script to the footer that allows the copyright year to automatically update to the current: – the results looks like this:

    © 2007 – 2018 WebsiteName

    This is the code:

    © 2007 - var d = new Date(); document.write(d.getFullYear()); WebsiteName

    Could you please advise: where & how do I adjust the child theme so that it will display correctly. Thank you.

    #69471
    Zed
    Cryout Creations mastermind

    The free theme has no dedicated JS field, so you’d need to use a plugin to add the code to your site. Then you’d need to format the target text in a way that lets you edit it with the companion JS.

    For example, use
    &copy; 2007 - <span id="copyyear">2018</span> WebsiteName
    in the text field and

    function update_copyyear(){
        var d = new Date();
        document.getElementById('copyyear').innerHTML( d.getFullYear() );
    }
    update_copyyear();

    for the JS.

    This code is untested


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Add java script to footer (child theme)’ is closed to new replies.