- This topic has 15 replies, 3 voices, and was last updated 4 years, 1 month ago by
David.
-
AuthorPosts
-
January 30, 2019 at 5:38 pm #797178
Jamie
Hi! I recently added google ads to my website. I have an ad in the header, which used to mean that it was displayed below my site title and menu which were side by side. For some reason, over the last week, the ad has moved to the right of the site title with the menu underneath, which looks bad. Do you know the reason this has changed, and how I can amend it back to how I originally had it?
Thanks!
January 30, 2019 at 7:13 pm #797227Tom
Lead DeveloperLead DeveloperHi there,
It looks like the ad is set to be auto-placed.
I think you’d need to choose one of their static ad types, then we could add it where you want using Hooks. Where exactly do you want it to show up?
January 31, 2019 at 6:38 am #797543Jamie
Hi Tom,
It would be great if I could have the ad below the site title and menu, but before the content starts in the white boxes? I’m thinking of in the grey bit after the site title and menu? or if this is not possible, in a section that is below the site title and menu?
January 31, 2019 at 8:39 am #797798Tom
Lead DeveloperLead DeveloperTo do that, you can create a new Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
Then add your adsense code into the content area of the hook.
For the actual hook, choose
generate_inside_container
.Then set the Display Rules and you should be good to go 🙂
April 19, 2019 at 7:37 am #873563Jamie
Thanks, Tom. This worked perfectly. However, what would be the best way to allow the ad to show on pc/desktop, but so it doesn’t show on mobile devices?
Thanks
April 19, 2019 at 7:54 am #873572David
StaffCustomer SupportHi there,
maybe this article will help:
April 19, 2019 at 8:16 am #873591Jamie
Hi David,
Thanks for the reply, but that appears to be for google ad words. I meant for google adsense where the random ads show up in a banner below my header. I want it to display on desktop but not on mobile.
Thanks
April 19, 2019 at 8:25 am #873597David
StaffCustomer SupportSorry my bad – i was looking for a way that didn’t require hiding it if possible, you could try wrapping it in the is snippet:
<?php if ( !wp_is_mobile() ) { /* adsense script here */ } ?>
April 19, 2019 at 8:33 am #873603Jamie
Thanks David, but that doesn’t seem to have worked. Can you see anywehre I’ve gone wrong with the code below, as where my ad should be it is just showing }?>
<?php if ( !wp_is_mobile() ) { <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Banner Ad --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6063761039490145" data-ad-slot="5447386469" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> } ?>
April 19, 2019 at 8:48 am #873617David
StaffCustomer SupportTry this:
<?php if ( !wp_is_mobile() ) { ?> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- Banner Ad --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6063761039490145" data-ad-slot="5447386469" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <?php } ?>
April 19, 2019 at 9:08 am #873636Jamie
I’m afraid that doesn’t work either, David. In fact, on mobile, ads are now stuck at the top of both the ‘submit’ and ‘contact’ pages, even though I’ve deleted the ad code and the hooks! Any idea how to get rid of them?!
April 19, 2019 at 9:08 am #873637Jamie
oh, and I’ve already tried deleting cache
April 19, 2019 at 9:11 am #873640Jamie
ignore me David, I’ve got rid of the ads for now. I’ll try this another time I think, unless you know anything else to try. If not, please enjoy your bank holiday long weekend (if you’re not working that is!) and thanks for trying.
Jamie
April 19, 2019 at 9:15 am #873644David
StaffCustomer SupportYeah sorry for the goose chase – we may just have to resort to CSS and hope Google doesn’t get mad. If you want to add them back in i can take a look at the CSS you need to hide it?
April 19, 2019 at 9:57 am #873668Jamie
I don’t want to make google mad! Just had a look at a plugin, and ‘Advanced Ads’ seems to be able to do what I’m after. I’ll give it a go over the weekend (unless you think it would be better without a plugin? I don’t want the site to slow down…) and get back to you if it doesn’t work.
-
AuthorPosts
- You must be logged in to reply to this topic.