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

    Hello,

    I’ve a question about adding some code to the header.php in the ChidTheme.
    For a site i need to add the code for the Google Tag Manger, you see this in the private area. The question is, do i need to copy the hole header.php for this and add the code there? Or is it possible just to copy a part of it in the childtheme?

    Because this provokes problems when the header file is update in the original theme, not? I there a solution for that?

    Thanks for helping me out!

    Best Regards

    #889128

    Hey Tim,

    Instead, please add following code to Functions.php file of your child theme

    function my_custom_code_head(){
    ?> 
    //Your code goes here
    <?php
    }
    add_action('wp_head', 'my_custom_code_head');

    Best regards,
    Yigit

    #889310

    Hi,

    Thanks you for the response.

    Do you mean I have to put the hole code in at the position: “//Your code goes here” ?

    Because the code of the Tag-Manager consist of two parts. One for in the <head> and the other after the <body> tag.

    Thanks for helping out!

    Regards,

    #889506

    Hi,

    The code you need after the body tag could be inserted using this:

    function my_custom_code_footer(){ ?>
    //YOUR CODE HERE
    <?php }
    add_action('wp_footer', 'my_custom_code_footer');

    Best regards,
    Rikard

    #889991

    Thank you! For helping!

    #890017

    Hey!

    You are welcome Tim, glad we could help :)

    Cheers!
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Customizing the header.php in a childtheme’ is closed to new replies.