• I’ve got this simple bit of code, that displays 10 entries. I want each div to have an alternating class (alt class for alternating rows). It also bypassed the 3 most recent posts. What’s the best way to achieve this? Thanks in advance!

    <?php
    $posts_query = new WP_Query(‘showposts=10&order=DESC’);

    while( $posts_query->have_posts() && ($post_count < 15) ) : $posts_query->the_post();
    $post_count++;
    if ($post_count<4)
    continue; ?>

    <div class=”archive alt<!– Need This To Alternate –>”>
    <h4>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></h4>

    <p><?php the_author_posts_link(); ?> | <?php comments_popup_link(‘Leave a Comment’, ‘1 Comment’, ‘% Comments’); ?>
    </p>

    </div>

    <?php endwhile; ?>

Viewing 1 replies (of 1 total)
  • Something like this?

    <?php
    $count = 0;
    ?>
    <div class="archive_<?php echo $count; ?>">
    <?php
      $count = ( $count == 1 ) ? 0 : 1;
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Alternating Displayed Entry Classes’ is closed to new replies.