[Resolved] Adsense code with hooks

Home Forums Support [Resolved] Adsense code with hooks

Home Forums Support Adsense code with hooks

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #616380
    Charalambos

    Hello,

    I have placed an ad code with gp hooks just below the title (After entry title). The ad appears ok in mobile version, however as you can see in the screenshot there is too little spacing between the title and the ad in the desktop version and as a result it covers part of the title letters.

    View post on imgur.com

    My question is how can i move the ad a bit down? I currently use the code below to center the add and show only in single posts.

    <?php if ( is_single() ) : ?>

    <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <!– Content Ad –>
    <ins class=”adsbygoogle”
    style=”display:block”
    data-ad-client=”xx-xxx-xxxxxxxxxxxx”
    data-ad-slot=”xxxxxxxxxxx”
    data-ad-format=”auto”></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    <?php endif; ?>

    thanks in advance

    Charalambos

    GeneratePress 2.1.3
    GP Premium 1.6.2
    #616381
    Charalambos

    thats the code i use below,

    <?php if ( is_single() ) : ?>

    <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <!– Content Ad –>
    <ins class=”adsbygoogle”
    style=”display:block”
    data-ad-client=”xx-xxx-xxxxxxxxxxxx”
    data-ad-slot=”xxxxxxxxxxx”
    data-ad-format=”auto”></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

    <?php endif; ?>

    #616527
    Leo
    Staff
    Customer Support

    Hi there,

    Try this CSS:

    .site-main .adsbygoogle {
        margin-top: 20px;
    }

    Adding CSS: https://docs.generatepress.com/article/adding-css/

    #616907
    Charalambos

    Hello,

    Thanks for your reply. So shall i add this css code in the hooks below the adsense code?

    Also just to clarify all the other ads look good. I only want to fix the ad below the post title.

    thanks

    Charalambos

    #617415
    Leo
    Staff
    Customer Support

    CSS should be added with one these methods:
    https://docs.generatepress.com/article/adding-css/

    I modified the code so it should only target that one.

    #617781
    Charalambos

    Hello,

    Thanks again, it works!

    #618036
    Leo
    Staff
    Customer Support
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.