[Support request] Google Ads in header

Home Forums Support [Support request] Google Ads in header

Home Forums Support Google Ads in header

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #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!

    #797227
    Tom
    Lead Developer
    Lead Developer

    Hi 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?

    #797543
    Jamie

    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?

    #797798
    Tom
    Lead Developer
    Lead Developer

    To 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 🙂

    #873563
    Jamie

    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

    #873572
    David
    Staff
    Customer Support
    #873591
    Jamie

    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

    #873597
    David
    Staff
    Customer Support

    Sorry 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 */
    }
    ?>
    #873603
    Jamie

    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>
    }
    ?>
    #873617
    David
    Staff
    Customer Support

    Try 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
    }
    ?>
    #873636
    Jamie

    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?!

    #873637
    Jamie

    oh, and I’ve already tried deleting cache

    #873640
    Jamie

    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

    #873644
    David
    Staff
    Customer Support

    Yeah 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?

    #873668
    Jamie

    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.

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.