WordPress.org

Ready to get started?Download WordPress

Forums

How to Add Content Between Posts (5 posts)

  1. soniaz
    Member
    Posted 3 years ago #

    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

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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

  3. ndamaren
    Member
    Posted 3 years ago #

    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

  4. chinmoy
    Member
    Posted 3 years ago #

    use custom field feature.

  5. ndamaren
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.