• I know this has been covered in part but I couldn’t find the enough to piece it together. Maybe I didn’t search for the right terms. Anyway:

    I need to add a css class to every third item in a loop.

    what I have now (not working):

    <?php if ($i % 3 == 0) {$style = 'team_list_last';} ?>
    <?php the_ID(); $parent = $post->ID; query_posts('post_type=page&orderby=menu_order&post_parent='.$parent); while (have_posts()) : the_post();?>

    then a simple <div class=”team_member <?php $style ?>”>

    This doesn’t work and I know its something simple. Any help is greatly appreciated.

    thanks

Viewing 1 replies (of 1 total)
  • maybe (?):

    <?php $i = 0; $style = 'team_list_last';
    the_ID(); $parent = $post->ID;
    query_posts('post_type=page&orderby=menu_order&post_parent='.$parent); while (have_posts()) : the_post();?>
    <?php $i++; ?>
    ....
    <div class="team_member <?php if ($i % 3 == 0) { echo $style; } ?>">
Viewing 1 replies (of 1 total)
  • The topic ‘how to add index to items in loop and add css class every 3rd’ is closed to new replies.