Hi, I'm trying to set up my blog so that it displays an 'Advertisement' post in between blog posts... ideally after every 2 posts, or something like that. Obviously I would like the advert to appear automatically, without me manually having to make a post after every 2 posts. Ideally it would work like it does on this website (scroll down about 2 or 3 posts until you can see the advertisement). Does anyone know of a simple way of doing what I want? Would there be a plugin suitable to use? Thanks for any help
This works for the default index.php: <?php if (have_posts()) : ?> <?php $post_count = 0; ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> ..... </div> <?php if ( ++$post_count == 2) { ?> <!-- advertisement code here --> <?php post_count = 0; } ?> <?php endwhile; ?> Code (markup):
Thanks for trying to help but thats not the kind of thing I want... I want to display a special "advertisement" blog post, so that my readers know that its a sponsored blog post. This is a screenshot of the kind of thing I want... Thanks for any help
I didn't bother looking at the website because I thought I understood. Oh well...try this then: <?php if (have_posts()) : ?> <?php $post_count = 0; ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> ..... </div> <?php if ( ++$post_count == 2) { ?> <div style="height: 320px; padding-top: 5px; margin-bottom: 20px; background-color: #EFEFEF"> <h4>Advertisement</h4> <div style="margin: 0 0 20px 80px;"> <!--- advertisement code here --> </div> </div> <?php } ?> <?php endwhile; ?> Code (markup): The style will need adjusting if your advertisement is a different size, and also if your post column is a different width.