WordPress.org

Ready to get started?Download WordPress

Forums

how to add banner between first and second posts ina loop (10 posts)

  1. mrak
    Member
    Posted 7 years ago #

    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?

  2. mrak
    Member
    Posted 7 years ago #

    any ideas on this one?

  3. Doodlebee
    Member
    Posted 7 years ago #

    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.)

  4. blackhood
    Member
    Posted 7 years ago #

    : )) Thx, i like the idea

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    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.

  6. Doodlebee
    Member
    Posted 7 years ago #

    Excellent, Otto...thank you...this is good to know ;)

  7. Boris
    Member
    Posted 6 years ago #

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

  8. ganzua
    Member
    Posted 6 years ago #

    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.

  9. moshu
    Member
    Posted 6 years ago #

  10. ganzua
    Member
    Posted 6 years ago #

    Thanks Moshu :) It worked great!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags