• Resolved aadje93

    (@aadje93)


    Hi,

    Could you help me edit the content/index page to show a (responsive) add on the homepage. OR if this is hard a header (responsive may bring a square add).

    Or if its possible, for instance a header when there’s enough room and no ad when there is no room for it (mobile). I tried adding it before the endwhile on the index, but i am no php expert. I truly dont understand php, only a little html :).

    If you could help me i would be very happy. Greetings Adriaan
    http://just-autism.com

Viewing 15 replies - 1 through 15 (of 16 total)
  • Theme Author acosmin

    (@acosmin)

    I think you can open index.php, find this line:

    <div class="posts-wrap clearfix">

    and add this code bellow it:

    <div class="clearfix" style="width:100%">
         your google adsense code goes here
    </div>
    Thread Starter aadje93

    (@aadje93)

    Edit, stupid me. Off course i need to look in index.php from the theme folder (must be the 10hour workday)
    Well, i added it, but i dont see a (responsive) add showing up. I will make a header ad code in adsense to try if that works. (also looking for a plugin that may can help with this, only show it articles older then 2 weeks for instance)

    Edit2, your code works!. But now i want to center it a little and add it after the first post if thats possible… (Responsive is working fine luckily!!!)

    Thread Starter aadje93

    (@aadje93)

    Can’t edit last post, but with the google publisher plugin i’m able to sort of blend in the add with the first post. But i want a header between the first and second post (check http://just-autism.com/ to see how it’s now)

    Opend index.php, find:

    if ( have_posts() ) :
    	while ( have_posts() ) :
    		the_post();
    		get_template_part( 'post-templates/content' );
    	endwhile;
    	else :
    		get_template_part( 'post-templates/content', 'no-articles' );
    	endif;

    change it with:

    if ( have_posts() ) :
            $count = 0;
    	while ( have_posts() ) :
    		the_post();
            $count++;
    		get_template_part( 'post-templates/content' );
            if ($count == 1) : ?>
               <article class="post-template-1 clearfix">
                  YOUR GOOGLE AD CODE GOES HERE!
               </article>
    <?php
            endif;
    	endwhile;
    	else :
    		get_template_part( 'post-templates/content', 'no-articles' );
            endif;

    Theme Author acosmin

    (@acosmin)

    ^^ wrong account, that was me.

    Thread Starter aadje93

    (@aadje93)

    Yeah working man!!!! Thanks freaking alot. Now only thing to fix is the gray background -> white :P. But the overall idea is good now!

    Could it be fixed if i make a adsense code with the option when no ads to display just use FFFF (white) so its fixed? Now its on blanc and i noticed when i make a new code it shows the same colour….

    Theme Author acosmin

    (@acosmin)

    Where you have this line:
    <article class="post-template-1 clearfix">

    change it to:
    <article id="myfirstad" class="post-template-1 clearfix">

    Now open style.css and at the bottom add:

    #myfirstad {
      background: none;
      background-color: #fff;
      border: none;
    }

    Thread Starter aadje93

    (@aadje93)

    Man, i realy don’t know how to thank you. It looks just as i want it now. Also responsive works great on the tablet (nexus 7) and resized browser screen. Realy thanks alot!

    Now i only need to make a child theme to keep it after a theme update right?

    I dont know about child themes…

    And do you also know how i can add this to the widget version of my ad? (so that one is also made white with the stylesheet css)

    Theme Author acosmin

    (@acosmin)

    No problem! I think you can change in style.css this:

    #myfirstad {
      background: none;
      background-color: #fff;
      border: none;
    }

    to:

    .adsbygoogle {
      background: none;
      background-color: #fff;
      border: none;
    }

    There is some extensive documentation regarding child themes:
    http://codex.wordpress.org/Child_Themes

    Also, you can leave a rating if you find this theme helpful:
    https://wordpress.org/themes/justwrite

    I am going to sleep. Good Night! πŸ™‚

    Thread Starter aadje93

    (@aadje93)

    Hi man, it looks like that solution is not working, but i want to thank you for all your hard work. (when the site loads you see grey background for a sec after ad shows up) I just can’t tell you how much i appreciate the work you’ve put into this topic to help me. I know very little about php/css but now the in-content ad looks fabulous πŸ™‚

    I was little mistaken. The display ads are still not doing the CSS correctly, only the adwords ads (in the custom theme specified on adsense page) are nicely blending in with the site. So maybe i will just disable display ads on the ad thats in-content

    Thread Starter aadje93

    (@aadje93)

    Can’t edit last post, but just using non-visual ads look perfect. so hereby resolved this topic! Thanks for your help acosmin

    I posted adsense ad after 5 post. Put now i want another after 10 post and another after 15 post. What i must add to the code? How the code should look like?

    Theme Author acosmin

    (@acosmin)

    Instead of if ($count == 1) try if ( ( $count % 5 ) == 0 )

    Thanks, it worked!

    Dear Acosmin, firtly thank you for the all of information. I would to use this code only on mobile view. So how can i do? Should i edit css or php?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘I want to post a adsense (responsive) add after first post’ is closed to new replies.