Archived topic
Adding HTML to header
20 replies · Started by Kiogora on June 6, 2021
Hi Team,
Am getting this message when I want to add html code to the header. Its google AdSense code
Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.
Thnaks.
Hi there,
never edit the Themes template files.
To add your code to your site you can use a Hook element:
https://docs.generatepress.com/article/hooks-element-overview/
To add code to the <head> you would use the wp-head hook.
Thanks for the reply .
When it comes to Display Rules
What should I choose
Entire site
Front page or blog
Thanks
That depends on where you want the code to be executed.
If you want the code to work on entire site then you would choose the entire site.
Hey Leo,
Am new in this field
This a google AdSense code where is the best place to display?
Thanks
Go with Entire site.
Hi Leo,
When I click publish am getting notification page can not be found.
Hmm. Does the same issue happen if you just add a simple text instead of the Adsense code?
Have not tried any other text
Can you give it a shot?
Simply create a new hook and add a text. Does that triggers an error?
No its not sending any error
Are you sure the code is copied and pasted correctly?
If so then something is blocking the code.
I'd recommend disabling all plugins except GP Premium to see if that resolves the issue.
If not, then please check with your hosting to see if there is some security built-in that stops the code from executing.
Thanks for the feedback.
I will contact my host and get back to you.
Hi Team,
The AdSense code was added but its not showing in the header I added A New Element Title then Hook then location (entire site) and published.
But if I look in the my Home and check page source to look where the code is I see it in a very different location. Find the code in page source using this
adsbygoogle.js
Now my question is, is that place where the code is header.php?
Is the code you're adding to Display the Advert ? ie. you want the displayed advert in the site header ?