WordPress.org

Support

Support » How-To and Troubleshooting » how to add banner between first and second posts ina loop

how to add banner between first and second posts ina loop

  • I wish to put advertistment (banner) in my loop

    what I want to do is to put it between first and second post on the page

    or even better, to insert banner after first post on the page

    is this possible?

Viewing 9 replies - 1 through 9 (of 9 total)
  • any ideas on this one?

    Doodlebee
    Member

    @doodlebee

    There’s a plugin for this – someone was talking about it on here the other day…I can’t remember what it’s called…

    I know I downloaded it, but I just came back from the eye doctor and I’m dilated all to hell and I can’t read my filenames (it’s so sad! LOL) But I *believe* it’s called something like “in between” – AH! there it is! “CG In Between” (Had to resize to 4x the normal font size and I feel like an old woman, but there you go.)

    blackhood
    Member

    @blackhood

    : )) Thx, i like the idea

    Samuel Wood (Otto)
    WordPress.org Tech Dude

    @otto42

    A somewhat simpler way is just to modify your loop.

    Before the loop, do something like this:
    $show_banner = true;

    Then, inside the loop, but at the bottom, do this:

    if ($show_banner) {
    // insert banner code here
    $show_banner = false;
    }

    And there you go. It’ll only show that banner once, right after the first post.

    Doodlebee
    Member

    @doodlebee

    Excellent, Otto…thank you…this is good to know 😉

    Boris
    Member

    @travel-junkie

    So how would I modify that if I wanted to show something after the second or third post? Thanks!

    I can’t make it work, what did I do wrong?

    <?php $show_banner = true;  ?>  
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    ...
    
    <div class="entrytext">
    
    <?php if ($show_banner); {  ?>
    //insert banner code here
    <?php $show_banner = false; } ?>
    ...

    I’d like to show just one banner on top left of the first post.

    Thanks Moshu 🙂 It worked great!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘how to add banner between first and second posts ina loop’ is closed to new replies.