[Resolved] Adding script to footer area or footer widget

Home Forums Support [Resolved] Adding script to footer area or footer widget

Home Forums Support Adding script to footer area or footer widget

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #1148283

    want to add a little bit of code that goes in front of the /<head> tag in the footer. I already have some text in the footer bar and would like this to appear above it. It’s a GDPR notice and will disappear when user clicks OK.

    Is it best to put it into the footer window or as a widget in the footer?

    Read some posts/info and created and activated the plug-in. But it doesn’t appear in the front page.

    Have I missed something? Thanks, here’s the code:

    <?php if ( is_front_page() ) : ?>
    Plugin Name: WAC GDPR plug
    Plugin URI:
    Version: 2020.1
    Author URI:
    License URI:
    <link rel=”stylesheet” type=”text/css” href=”//wpcc.io/lib/1.0.2/cookieconsent.min.css”/>

    <script src=”//wpcc.io/lib/1.0.2/cookieconsent.min.js”></script>
    <script>window.addEventListener(“load”, function(){window.wpcc.init({“border”:”thin”,”corners”:”small”,”colors”:{“popup”:{“background”:”#edeff5″,”text”:”#838391″,”border”:”#edeff5″},”button”:{“background”:”#0073ff”,”text”:”#ffffff”}},”content”:{“message”:”This website uses cookies (including 3rd party: Google analytics + Facebook links) to help improve website function and user experience. Our Privacy Policy explains how and why.”,”href”:”https://www.warlinghamarchers.uk/cookie-policy&#8221;,”link”:”See the Privacy Policy”}
    <?php endif; ?>

    Customer Support

    Hi there,

    you can use the Hook Element to add the script:


    The WP_footer hook is in the footer.


    Thanks David,
    read all that, added element with the code BUT where do I put the code listed under Hooks/Usage here

    PS do I need to create a child theme to preserve these elements?


    Customer Support

    No child theme required if using the Hook Element.
    Appearance > Elements > New –> Hook.
    Add your code to the content text area.
    Select the WP_Head hook and check Execute PHP.
    Then on the Display Rules tab – set the Location where you want the script to fire e.g Entire Site


    Thanks David,
    checked live site and it worked – sort of. I used the hook ‘generate before footer’ and thought it might stick above the footer if I scrolled up/down the page – instead it moves up/down screen with me.
    I’m not too bothered by that but just wondered, for future reference, is there a hook that would stick it to the footer.

    Customer Support

    In this instance the hook you choose has no baring on the position of the cookie notice.
    What the hook is doing is simply adding some code that gets executed by the browser. It is the code that is responsible for how and where the cookie notice is displayed.

    I am not sure where the code comes from – but maybe the offer some other ‘styling’ options.


    That’s fine. Thanks David

    Customer Support
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.