Archived topic
Header.php overwritten
3 replies · Started by Micha on June 26, 2019
Hello,
after the update of your theme my Header.php was overwritten.
Which is very bad, because it contains the google tag manager.
but because I found it right away, I was able to solve the problem.
I hope it won't happen with the next update.
best regards
Micha
Hi there,
you should never make changes to the parent theme function files as they will always be overwritten when the theme updates.
If you need to make changes to a function or a template then you need to use a child theme.
The easiest and safest way to add the GTM codes is to use the Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Create a new hook. Add your first GTM code to its content. Select the WP_head Hook from the list. And set your display rules to Entire Site.
Repeat this for the second code ( the one that is required within the Body) but use the before_header hook, and set priority 0.
Hi David,
thanks for the info. I'll take a look and create a child theme.
best regards
Micha
You're welcome