Code in the header with a child theme?

  • Ricardo


    I would like to add a piece of code to my header:

    <script type="text/javascript" src=""></script>

    But, of course, every time I would update the theme I would have to add the code manually again. Is there a way to implement the code somewhere (child theme maybe?) so that it would also be there after an update?


    Kenneth John Odle


    The best way is to use an action in your functions.php file of your child theme. and attach it to the “wp_head()” action hook.



    I am going to ask you for some more help on this one (Googled it first of course). How do you attach it to the action hook?



    Can you just create an action hook in the header.php, try the graphene_container_before.

    I don’t think the script will show anything, and I haven’t tested this, but give it a try and see what happens.

    I’m curious 🙂



    That actually works! Thanks 🙂

    (Because my buttons counter still read mysterious numbers, I chose to add the 3 buttons myself without a counter)



    Awesome. Great to know.

    Yeah, I’ve seen a lot of people having issues with the counters using various social sharing.

    Glad you got it working!

    ALSO: This might be a good place to store any scripts in the future that require being placed in the header. I know various add-ons require a script code in the header. Maybe this could be used like a “script tank”??

    Thanks for testing!



    I was thinking exactly the same. It’s really frustrating when loose the code before updating and you have to search for it again 😉

Viewing 7 posts - 1 through 7 (of 7 total)

  • You must be logged in to reply to this topic.
Do NOT follow this link or you will be banned from the site!