• I’m using WordPress 2.7 and I was just wondering how can i make it so that on the home page where it shows the last 10 posts, is it possible to inject specific ad-code inbetween the 5th and 6th post within the loop?

Viewing 1 replies (of 1 total)
  • There’s probably a more WordPress-friendly way, but a simplistic hack would be to look at the index template –

    <?php while (have_posts()) : the_post(); ?>

    … stuff …

    <?php endwhile; ?>

    In between the while and endwhile, you could have a counter, that adds up stuff, so when it gets to 5 you print your ad block.

    So it’d be something like

    <?php my_counter = 0;
    while (have_posts()) : the_post();
    my_counter = my_counter + 1;
    ?>

    … stuff …

    <?php if (my_counter == 5) { ?>
     ... put your ad block html here ...
    <?php } ?>

    <?php endwhile; ?>

Viewing 1 replies (of 1 total)

The topic ‘Inject Ads’ is closed to new replies.