• If I wanted to display an adsense banner on the home page, but only after the most recent post, what would i need to wrap the adsense code in?

Viewing 15 replies - 16 through 30 (of 39 total)
  • Yeah, Beel, I read the f*ing manual. I already know that this is the index.php in the Theme folder aka Main Template. I tried using an elseif statement and it didn’t work. I tried adding a second iteration of this using <?php if ($postnum == 2...etc. and that didn’t work. I tried adding a second variable called “showadsenseagain” and then `<?php if ($postnum == $showadsenseagain) …” and that didn’t work. I didn’t see a damn thing in the Site Architecture of WordPress that really answered the question of how to modify this little routine to output the code a second time after the second post, but thanks anyway.

    Testy aren’t we? Check the thread a bit more closely and you might see my comment had nothing to do with you. Then you might check out David Chait’s CG-Inbetween. That should work for you. There are also threads you could search for where we posted how to add counters, etc., to the code to do what you want (but David’s plugin makes life easier).

    Yeah, I guess so. I was the one that mentioned tinkering, so it looked like you were responding to me.

    What about AdSense BEFORE first post only… anyone know how that would work?

    Exactly the same except you’d put the code before the_content instead of after the_content.

    nevermind, justed placed AdSense code above the loop, under the content div

    Very valuable information, thanks!

    I wonder if it is possible to display an image or a banner instead of adsense…

    /Erico

    Yeah. It’s also possible to display other types of ads like Adbrite or Yahoo Publisher Network. Instead of Adsense code, think “Advertising code”.

    It works very well. Thanks!
    /erico

    This works great! Is there a way to put a </br> immediately after the adsense block? Mine looks a little cramped.

    https://motorcyclebloggers.com

    Nghia

    (@nghia)

    guys,

    i cannot find this line anywhere in the index.php
    I have 1.5.2, is it normal?

    I can’t find the LOOP line, i’m using Blix..and it seems that the loop is either in another file or written in another, anyone can help?

    Heat

    I’m using the latest wordpress and Blix too. The code for the php seems depricated or something. Try this: Before “<?php while (have_posts()) : the_post(); ?>” insert

    <?php $showAdSense = True; ?>

    Now, before “<?php endwhile; ?>” insert
    <?php if ($showAdSense): ?>
    your adsense code
    <?php $showAdSense = False; ?>
    <?php endif; ?>

    That should work. Hope this helps.

    what if you like it to show on 1st, 2nd and 3rd post?

    Yea, like janjalani, I just want to put an adsense block within just the first two posts on the main blog page and then on the single page (permalink pages) have the adsense block always displayed within the post…???

Viewing 15 replies - 16 through 30 (of 39 total)
  • The topic ‘Adsense after first post only’ is closed to new replies.