Support » Themes and Templates » How to Add Content Between Posts

  • Hey there,
    I’m looking to add a few linked images between posts on my blog I want to use these images as advertisements for our store. Does anyone know how I can tweak my main index template so that I can include linked images between posts?

    I want different images throughout the page, so for example:
    Image A would sit between posts 2 and 3
    Image B would sit between posts 4 and 5

    Thanks so much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    in priciple, add a counter variable to the loop; use if statements to show the banner ads; increment the counter before the endwhile of the loop.


    <?php if (have_posts()) :
    $counter = 1;
       while (have_posts()) :
    if($counter == 2) { ?>
    html code for A ad banner
    <?php } elseif( $counter == 4 ) { ?>
    html code for B ad banner
    <?php } elseif( $counter == 6 ) { ?>
    html code for C ad banner
    <?php }
    endif; ?>

    repeat as many elseif blocks as you need


    i’ve tried to use this code but i am also using this code to display the first image of each post on the homepage. this ad counter code brings all the other content into the homepage.

    any work around for this?


    use custom field feature.

    can y ou elaborate on that? new to all this. thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Add Content Between Posts’ is closed to new replies.