I don't deal with Wordpress or PHP really at all, our dev left last year and we've just muddled through really.
I'm fine with adding in scripts and what not, but this specific script has to be the first script loaded under the head tag.
I can't for the life of me get it to work, every question I've read on here offers the same advice (which I've tried) using enqueuing and it's just not changing anything.
I've also tried adding the snippet directly under the tag in the header.php file, no joy. It's almost as though something else is forcing the other scripts to be ordered above it.
The script I've tried:
function my_custom_js() {
echo '<script type="text/javascript"> window.hfAccountId = "ACCOUNT_ID";
window.hfDomain = "DOMAIN";
(function() {
var hf = document.createElement("script"); hf.type = "text/javascript"; hf.async = true;
hf.src = window.hfDomain + "/scripts/hf.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hf, s);
})();
</script> ';
}
// Add hook for admin <head></head>
add_action( 'admin_head', 'my_custom_js', -1000 );
// Add hook for front-end <head></head>
add_action( 'wp_head', 'my_custom_js', -1000 );
This is just one of some variations I've tried, this one specifically I read to put in the functions.php file, so I did.
I've also tried adding to the functions > enqueue.php file... no joy.
It appears perfectly fine on the site, just not in the right place.
Please help!