admin管理员组

文章数量:1293314

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 = '.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

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

Share Improve this question asked May 5, 2021 at 9:23 HennoHenno 1 5
  • above the </body> tag. – Henno Commented May 5, 2021 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 Commented May 5, 2021 at 9:41
  • No, not in the <head> tag, but above the </body> tag – Henno Commented May 5, 2021 at 9:43
  • Oh, than you can use the wp_footer action – Buttered_Toast Commented May 5, 2021 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 Commented May 5, 2021 at 10:20
Add a comment  | 

1 Answer 1

Reset to default 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');

本文标签: functionsNeed to put a script above ltbodygt tag in headerphpWP 571