Archived topic
how to add auto ads from adsense in theme
14 replies · Started by jaya swaroop on February 27, 2018
i like to add auto ads from adsense to our theme
please help me to resolve
Hi there,
Check out this thread: https://generatepress.com/forums/topic/google-adsense/
nothing was changed in my website
resolve my problem
Where and what was the code you've added?
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-xxxxxxxxxxxx",
enable_page_level_ads: true
});
</script>
i added the code in wp_head
Hello leo
generatepress theme will support autoads or not
I believe Google asks that part of the code to be in the <head> section correct?
If so wp_head hook is what you are looking for:
https://docs.generatepress.com/article/wp-head/
https://docs.generatepress.com/article/hooks-overview/
hello leo i added in the same part wp_head no improvements
jaya -
Where are you wanting the ads to appear?
For example, if you want them to appear in a sidebar, then add an HTML widget to the sidebar location and paste the AdSense code into it and Save.
Or, if you want to have the ad appear at the top of the page, add the code to the Before Header GP Hook location.
You can also get fancy and use PHP to conditionally display the ads in the various GP Hooks locations. On one of my sites, I have it set to display the ad only on single posts and below the content.
This is what I do on all of my sites that have Google AdSense ads :)
Cheers!
Lyle
Lyle, thanks a lot for the tips! I have already ads running on my blog, by this moment there are maximum 2 appearing per page https://www.karikfood.com
and I tried your first suggestion in order to add extra ads (this time Auto Ads), adding HTML widget on sidebar area, but it seems it doesnt work. Did I make something wrong? Maybe it is not compatible with already existing ads or plugin (WP QUADS - Quick AdSense).
You got a few console errors coming from the ads which I believe is causing them not showing:
http://www.screencast.com/t/8W7MnOni3
Might be worth checking with the source of wherever you got the code/ads.
Leo, thanks for your swift reply. Don´t understand well what exactly I have to do. Will I quit that HTML widget area with the code within put in the sidebar?
Actually this is the error: http://www.screencast.com/t/7dcV6eUSx
Someone else had a some error yesterday: https://generatepress.com/forums/topic/problems-with-google-ads-recommended-content-block/#post-597549
Have these methods changed, in the age of Elements if you will?
That is, having installed Elements, how might I add adsense auto ads?
The Code Snippets plugin seemed to crash my site.
Thanks
You can use the wp_head hook in Hooks Element:
https://docs.generatepress.com/article/hooks-element-overview/
If you need more help on this, please open a new topic :)
Thanks!