• i need to add an ad between the 3d and 4th post experts in my home page

    <?php while (have_posts()) : the_post(); ?>
    					<!-- Start: Post -->
    					<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    						<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    						<p class="postmeta">Posted on <a href="<?php the_permalink() ?>"><?php the_time('F jS, Y') ?></a> by <?php the_author() ?></p>
    						<div class="entryContent">
    						    <?php the_post_thumbnail(); ?>
    							<?php the_excerpt(); ?>
    						</div>
    						<p>Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> </p>
    					</div>
    					<div class="clear"></div>
    					<!-- End: Post -->
    				<?php endwhile; ?>

    is there a way to do this

Viewing 1 replies (of 1 total)
  • one possible way is to use a counter variable and increment/check it within the loop:

    <?php while (have_posts()) : $counter = 0; the_post(); ?>

    <?php $counter++; if($counter == 3) { /*show ad*/; }; endwhile; ?>

    (untested; only the edited lines shown)

Viewing 1 replies (of 1 total)
  • The topic ‘Ads between posts in homepage’ is closed to new replies.