Head Tags in Child Theme?

1 replies
  • WEB DESIGN
  • |
Sometimes, a plugin or css script requires you to add some html in between the head tags of your theme.

The header.php file is in the parent theme right? That's where the head tags are right? But I think I'd like to put the html in the child theme, so it's not overwritten by the next theme update. So, can I create a header.php file for the child theme and put the html code in there?

Would this allow my plugin to work properly, and not have to recopy html code in the head tags after each time I update the theme?

Would this work? And would there be any issues with this I'd need to know? Thanks.
#child #head #tags #theme
  • Profile picture of the author savidge4
    Jeff,

    I personally am not a big fan of template modification unless you absolutely have to. Adding a bit in the code for me personally would not be one of those times. When modifying a page's layout or the like.. then yes that is something that has to be done in the template itself.

    I would suggest using the below as a method to insert code into your header.php template and you would insert this into your functions.php file. With a real quick study, you could even turn this into a real quick plugin and add the wanted effect in thatmanor.

    Here is the code suggestion:
    PHP Code:
    add_action('wp_head', 'wp_add_function_wp_head');
    function wp_add_function_wp_head(){
        //Close PHP tags 
        ?>
        ADD YOUR HTML CODE HERE
        <?php //Continue PHP tags
    }
    Originally Posted by Jeff Burritt View Post

    Sometimes, a plugin or css script requires you to add some html in between the head tags of your theme.

    The header.php file is in the parent theme right? That's where the head tags are right? But I think I'd like to put the html in the child theme, so it's not overwritten by the next theme update. So, can I create a header.php file for the child theme and put the html code in there?

    Would this allow my plugin to work properly, and not have to recopy html code in the head tags after each time I update the theme?

    Would this work? And would there be any issues with this I'd need to know? Thanks.
    Signature
    Success is an ACT not an idea
    {{ DiscussionBoard.errors[10246121].message }}

Trending Topics