0

I need to put this script above the tag in the header.php.

window.Futy = { key: '0000000000' }; (function (e, t) { var n = e.createElement(t); n.async = true; n.src = 'https://v1.widget.futy.io/js/futy-widget.js'; var r = e.getElementsByTagName(t)[0]; r.parentNode.insertBefore(n, r); })(document, 'script');

But with the new header.php and hooks and function.php I don't know how to do this. I'm not a developer. So please tell me in a easy way as possible

5
  • above the </body> tag. – Henno May 5 at 9:25
  • If you mean that you want to put the code in the <head> tag, than you need to hook into wp_head action – Buttered_Toast May 5 at 9:41
  • No, not in the <head> tag, but above the </body> tag – Henno May 5 at 9:43
  • Oh, than you can use the wp_footer action – Buttered_Toast May 5 at 9:47
  • Okay, thanks. But I'm completely new with this kind of wp_footer actions, hooks, etc. Can you help me with this? – Henno May 5 at 10:20
2

As @Buttered_Toest mentioned, this snippet works well.
(This code goes to functions.php)

function futy_widget_footer(){ ?>
    <script>
        window.Futy = { key: '0000000000' }; (function (e, t) { var n = e.createElement(t); n.async = true; n.src = 'https://v1.widget.futy.io/js/futy-widget.js'; var r = e.getElementsByTagName(t)[0]; r.parentNode.insertBefore(n, r); })(document, 'script'); 
    </script>
<?php } 

add_action('wp_footer','futy_widget_footer');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.