Hi guys,
I just signed up for an exit-intent popup solution. The installation instructions are to “Place this javascript code snippet in the <head> tag of the page.”. What is best practice for installing this within enfold?
Thanks!
Best,
Jonathan
Hey Jonathan!
Please go to Appearance > Editor and open Header.php file and place inside <head> tags
Cheers!
Yigit
Thanks! It looked more difficult online when searching as there were things about hooks and such. No chance that this will break anything? Or is it best to use a plugin to insert headers?
Hey!
You can use the wp_head action hook if you don’t want to edit header.php file. http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
Something like this:
function add_custom_script(){
?>
<script>
SCRIPT HERE
</script>
<?php
}
add_action('wp_head', 'add_custom_script', 10);
Cheers!
Ismael
Oh ok so I can just insert this into custom.css instead of modifying the header.php file?
Hey!
You can add it on Appearance > Editor > functions.php file. Place it at the very bottom. Replace this line with your own script:
<script>
SCRIPT HERE
</script>
Regards,
Ismael
Ok, thank you. I apologize for all the questions.
Last thing I’m curious about – I don’t understand which way is better, to insert the script directly into the header.php file or to use the hook? If they both accomplish the same thing. Am I right in assuming that if I’m not using a child theme then just insert into header.php and keep a log of my edit to repeat on theme updates, and if I’m using a child theme then the hook is the way to go?
Thanks again for all your assistance.
Best,
Jonathan
Hi!
Both is good but using the hook is update proof. Just add it on the child theme’s functions.php.
Cheers!
Ismael
Ok perfect, thank you!