• First of all, thanks for this theme. It’s extremely well-done and looks great.

    I have a problem with the implementation of responsive ads in mobile views. I’ve tried putting ad code in the PHP files themselves and also using the Ad Injection plugin. The problem I’m running into is that for ads that appear in the post body (i.e. above of below post content), the expanding sidebar is causing Google to see the width of the page as wider than it actually is, so instead of getting a 300×250 size ad in mobile view it’s dropping a 728×90 ad which gets cut off because the page width isn’t anywhere near 728 pixels.

    So I was wondering if there was a patch, workaround, or fix for something like this. Every other WP theme I’ve used implements this correctly; on wider desktop screens the ads display at 728×90 or larger, and in mobile view it drops to 300×250.

    I don’t want to turn off sidebars in mobile view because they contain essential site navigation.

Viewing 8 replies - 1 through 8 (of 8 total)
  • HI smackbomb. Can you post a link to your site? Thanks.

    Thread Starter smackbomb

    (@smackbomb)

    I took a look at both sites. Guess I’m not following what you’re describing. Can you point to a specific page/post on which this occurs?

    Thread Starter smackbomb

    (@smackbomb)

    Apologies – I had them removed. I should have put it back so you could see – sorry.

    I put the ad back above the posts on https://www.unofficialsurvivorguide.com

    Thanks for taking a look.

    I’m thinking there must be some conflict between the theme and the plugin, although I’m not sure what it would be. I’ve helped several users successfully add dynamic sidebars with responsive ad content both within post content and within the loop between posts.

    Thread Starter smackbomb

    (@smackbomb)

    I’m not married to the plugin; I just want to be able to put responsive ads above posts. If you have another method please do let me know. Thanks again for your time.

    Give this a try and see how it works:
    1. Theme Options > Sidebars, add a new sidebar with a title and id of something like “Post Ads” and “post-ads” (they don’t have to be the same).
    2. In Widgets, drop a text widget in the Post Ads sidebar and insert your ad code.
    3. Copy single.php from the parent theme to your child theme.
    4. Add the dynamic sidebar in single.php just above the post title:

    <?php while ( have_posts() ): the_post(); ?>
    	<article <?php post_class(); ?>>
    		<div class="post-inner group">
    
    <?php dynamic_sidebar( 'post-ads' ); ?> 
    
    			<h1 class="post-title"><?php the_title(); ?></h1>
    			<p class="post-byline"><?php _e('by','hueman'); ?> <?php the_author_posts_link(); ?> · <?php the_time(get_option('date_format')); ?></p>

    5. Position it using css.

    I’m also working on this issue with another user and ran across this post on one of the threads I read:

    I’ve tried helping others with AdSense resizing problems before, and the problem is that the ads get output inside an iFrame. When you pick a particular ad format, you pick a specific size, and the iFrame code comes with the width & height attributes set. While you can override the size attributes for the iFrame by adding width & height CSS properties, you can’t touch the contents of the iFrame with CSS, since it reflects the contents of another site, so resizing the iFrame, e.g., making it smaller for a narrower view port, will generally cut off parts of the ad.

    This problem is more apparent in AdSense ads which have a wide, horizontal format which are intended to fit in the main content area of a page, rather than the vertical, tall thin ads which are intended to fit inside a sidebar. So if you do have the wider ads, I would consider switching to the vertical ones and putting them in a sidebar, or in a narrow widget area of the footer.

    I also found a couple of articles related to responsive Google ads; maybe one of them will help:
    How to Use Google AdSense Ads on Responsive Websites
    How to add Google AdSense Responsive Ads to WordPress

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Problem with responsive ads’ is closed to new replies.