Add Class After 4th Post

I need to add a “div” after the 4th post. I am showing 8 posts on the page and the code i am using above shows the div after the 4th and 8th… o just need the 4th to show not every 4th, just after the first 4th.

<?php if (have_posts()) : $count = 0; ?>
  <?php query_posts("showposts=8&post_type=vender_list&orderby=rand");?>
   <?php while (have_posts()) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php echo eh_postImage(240,240,1); ?>
     <?php the_title(); ?>
     <?php the_content_rss('', FALSE, '', 60); ?>
    </article>
<?php if ($count % 4 == 3) { ?>
<div class="vender_hr"></div>
<?php } ?>
   <?php $count++;  ?>
<?php endwhile; endif; wp_reset_query();?>

Solutions Collecting From Web of "Add Class After 4th Post"

Just check $wp_query->current_post instead of using that mod operator.

if ($wp_query->current_post === 4) { ?>
    <div class="vender_hr"></div>
<?php }

But don’t use query_posts. Create a new WP_Query object. What you are doing is kind-of weird. You are checking to see if there are posts, then clobbering the main query which invalidates the have_posts check you just did, and then Looping though the post set. That really should look something more like this:

$qry = new WP_Query("posts_per_page=8&post_type=post&orderby=rand");
if ($qry->have_posts()) { 
  while ($qry->have_posts()) {
    $qry->the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php echo eh_postImage(240,240,1); ?>
    <?php the_title(); ?>
    <?php the_content_rss('', FALSE, '', 60); ?>
    </article><?php 
    if ($qry->current_post === 4) { ?>
      <div class="vender_hr"></div><?php 
    } 
  }
} 

Also, the_content_rss has been deprecated since WpordPress 2.9. If you had debugging enabled as you should have while you are working, you’d see the notice.