Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1369201

    Hi

    I want to add head script code into the website.

    Is the best way via Child Theme?
    What is the process and where is the Child Theme download?

    Thanks
    Marcus

    #1369210

    Hey woogie07,

    You can use a function like this in functions.php:

    function woogie07_add_custom_code_head(){
    ?>
      YOUR SCRIPT GOES HERE
    <?php
    }
    add_action('wp_head', 'woogie07_add_custom_code_head');

    A child theme can be downloaded here: https://kriesi.at/documentation/enfold/child-theme/

    Best regards,
    Rikard

    #1369211

    Thanks,

    Is that code you supplied based on adding the child theme first or can I do this without the child theme?

    Do I need to change your references to woogie07 foir whatever name I want?

    Thanks

    #1369214

    Hi,
    You could add the function container above to the parent theme but when you update it would be lost as the functions.php file is overwritten.
    It would be better to first add a child theme and then add this to the child theme functions.php, please note that if you have more custom functions each one must have a different name, so your second function could be named like this:

    function second_add_custom_code_head(){
    ?>
      YOUR SCRIPT GOES HERE
    <?php
    }
    add_action('wp_head', 'second_add_custom_code_head');

    Best regards,
    Mike

    #1369223

    Thanks for this,

    So function 1

    function first_add_custom_code_head(){
    ?>
    YOUR SCRIPT GOES HERE
    <?php
    }
    add_action(‘wp_head’, ‘first_add_custom_code_head’);

    function 2

    function second_add_custom_code_head(){
    ?>
    YOUR SCRIPT GOES HERE
    <?php
    }
    add_action(‘wp_head’, ‘second_add_custom_code_head’);

    and so on…?

    #1369229

    Hi,

    Yes, you can do it like that if you want.

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.