WordPress.org

Support

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

How to Add Content Between Posts

  • Hey there,
    I’m looking to add a few linked images between posts on my blog Pawesome.net. 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.
    -s

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

    @alchymyth

    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.

    schematic:

    <?php if (have_posts()) :
    $counter = 1;
       while (have_posts()) :
          the_post();
          the_content();
    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 }
    $counter++;
       endwhile;
    endif; ?>

    repeat as many elseif blocks as you need

    http://codex.wordpress.org/The_Loop_in_Action
    http://www.htmlite.com/php015.php

    ALCHYMYTH,

    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?

    -ndamaren

    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.
Skip to toolbar