Site logo

Archived topic

adsense code with hooks

9 replies · Started by Immi on August 2, 2019

Viewing posts 1–10 of 10

I'm using Adsense banner with GP hooks at Before Content.
The ad appears large in mobile devices. I want to display it small for mobile devices. The desktop view appears, ok.
can you provide me CSS code for smaller ad banner

Hi there,

you would need to set that up within the Adsense advert itself - there should be responsive options.

Hello, David sir I have selected responsive in Adsense but still showing bigger.
it's possible to make smaller by CSS code for mobile devices

Could you link me to a post where i can see the Advert?

**

yes, Sir,

I have attached a screenshot.
**

There isn't much we can do about this - Adsense detects the size of the device and serves up a file to fit that size.

The most we can try is to wrap the Adsense code inside a div with a CSS class that we can set the width of:

<div class="ad-container">
Your adsence code here
</div>

Then this CSS which will ad some left and right padding on mobile to reduce the content width available:

@media (max-width: 768px) {
    .ad-container {
        padding: 0 30px;
    }
}

Not sure if it will help but thats about as much you can do - you cannot style content using CSS that comes from a 3rd party server.

Sir, I have placed this code in GP hook-like this:
can you have a look this is ok

**

That is correct - although if you want you can remove the if conditional ie.

<?php if ( is_page() || is_single() ) : ?> .... <?php endif; ?>

And use the Display Rules in the Hook Element to set it to display on Pages and Posts

Thank You David Sir,

You're welcome

This archived topic is closed to new replies.