- This topic has 17 replies, 3 voices, and was last updated 10 months, 3 weeks ago by David.
November 3, 2019 at 8:50 am #1052121Junaid
I want to add my Adsense auto ads code to my AMP version of the site. Please help me to insert auto ads code to AMP version of the site.November 3, 2019 at 8:45 pm #1052501TomLead DeveloperLead Developer
This depends on where you want to add it.
You can use a widget in Appearance > Widgets.
You can also use a Hook Elements in our Elements module: https://docs.generatepress.com/article/hooks-element-overview/
Hope this helps 🙂November 3, 2019 at 8:59 pm #1052508Junaid
Thank you for your wonderful support. I want to add one code to header of AMP and the other in the body of the AMP version. Can you please guide me in this regard?November 3, 2019 at 9:01 pm #1052509Junaid
Kindly be specidic in this regard, so that I could easily add codes before </head> and before </body> tags.November 4, 2019 at 4:59 am #1052688DavidStaffCustomer Support
in the Hook Element you can choose the following hooks:
WP_head – this is inside the
WP_footer – this appears close to the
Each hook can be given a priority. A low number (1) places the code first, a higher number moves it down the stack. So a higher priority number is required to move it closer to the
</body>November 4, 2019 at 5:38 am #1052709Junaid
I will try it. Will it add code to my AMP version of the site? I’m actually trying to add code to my AMP version of the site.November 4, 2019 at 5:41 am #1052711Junaid
I’m sorry but I couldn’t find any option for Hooks in my theme options. Where can I find it?November 4, 2019 at 6:36 am #1052765DavidStaffCustomer Support
in Appearance > GeneratePress activate the Elements module:November 4, 2019 at 6:38 am #1052767Junaid
Well, I got the Hook option. But can you please be specific how can I use this option to add code to AMP version of my site? There are options like,
And in settings there are two options, execute PHP and Execute Shortcodes.November 4, 2019 at 6:42 am #1052774DavidStaffCustomer Support
The two hooks i provided are WP Hooks so should be available in the Amp pages as well.
To make it so it only appears on Amp pages would require the scripts to be wrapped in a Conditional code, which you would need to ask the Amp plugin author about.November 4, 2019 at 7:20 am #1052813Junaid
Thanks, I will try it and let’s see if it works.November 4, 2019 at 7:21 am #1052816DavidStaffCustomer SupportNovember 4, 2019 at 10:31 am #1053064Junaid
I have placed the code but it’s not working. How can I check if the code is placed accurately?November 4, 2019 at 10:56 am #1053096DavidStaffCustomer Support
On the desktop browser – right Click > Inspect. The Dev tools will open and you will see the DOM – expand the <head> and look for the scripts you added.
Make sure in the Hook Element you set the Display Rules to Entire site.November 4, 2019 at 9:11 pm #1053458Junaid
Yes, I had set for entire site and selected PHP execution.
- You must be logged in to reply to this topic.