Archived topic
Adsense code with hooks
6 replies · Started by Charalambos on July 5, 2018
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.
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() ) : ?>
<!-- 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
thats the code i use below,
<?php if ( is_single() ) : ?>
<!-- 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; ?>
Hi there,
Try this CSS:
.site-main .adsbygoogle {
margin-top: 20px;
}
Adding CSS: https://docs.generatepress.com/article/adding-css/
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
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.
Hello,
Thanks again, it works!
No problem :)