• Resolved amandalubow

    (@amandalubow)


    I’ve added a basic script to display my cookie preferences widget from CookieYes. It’s set to be added in the <head> but it doesn’t seem to be working. I tried as both JS and as HTML and neither worked. I also tried as PHP, but there’s no way to specify that it should be in the header.

    Script is just this:

    <!-- Start cookieyes banner -->
    <script id="cookieyes" type="text/javascript" src="https://cdn-cookieyes.com/client_data/randomnumbershere/script.js"></script>
    <!-- End cookieyes banner -->

    Any ideas on why it’s not working correctly? I did try deactivating my optimization plugin already, but that didn’t help.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Atif Riaz

    (@lightbulbman)

    Hey @amandalubow ,

    Thanks for your message, does this not load on the page at all – as in the script tag does not display? I did check the link you shared and it is on the page but not sure if this is via the code snippet plugin.

    Another way and perhaps better way or more wordpress way would be to enqueue this using wordpress inbuilt wp_enqueue_script function – which is a php function and needs a php snippet – this registers the script with wordpress:

    function enqueue_cookieyes_script() { wp_enqueue_script('cookieyes', 'https://cdn-cookieyes.com/client_data/randomnumbershere/script.js', array(), null, false); } add_action('wp_enqueue_scripts', 'enqueue_cookieyes_script');

    The “false” parameter ensures it loads in the header rather than footer.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.