Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #335126

    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

    #336187

    Hey Jonathan!

    Please go to Appearance > Editor and open Header.php file and place inside <head> tags

    Cheers!
    Yigit

    #336486

    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?

    #336560

    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

    #336565

    Oh ok so I can just insert this into custom.css instead of modifying the header.php file?

    #336634

    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

    #336886

    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

    #337178

    Hi!

    Both is good but using the hook is update proof. Just add it on the child theme’s functions.php.

    Cheers!
    Ismael

    #337409

    Ok perfect, thank you!

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Code in tag’ is closed to new replies.