Support » Fixing WordPress » Alternate Post BG color

  • I know this has been done before and, with just a few lines of php I’m sure, can easily be accomplished again. Most of the places I could find this talked about were fairly outdated, so I was hoping someone would have a working, updated solution.

    Here’s an example loop I have:

    <?php $my_query = new WP_Query('category_name=sale&showposts=20');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID; ?>
        <div class="entry">
          <h2><a href="<?php the_permalink(); ?>">
            <?php the_title(); ?>
            <?php foreach((get_the_category()) as $cat)
     { echo '<img src="' . $cat->cat_ID . '.gif"
    alt="' . $cat->cat_name . '" />'; } ?>
          <div class="date"><img src="<?php bloginfo('template_directory'); ?>/images/clock.gif" alt="Date" />
            <?php the_time('n/j/y g:i A') ?> <img src="<?php bloginfo('template_directory'); ?>/images/user.gif" alt="Seller" /> <?php the_author_posts_link(); ?> <img src="<?php bloginfo('template_directory'); ?>/images/views.gif" alt="Views" /> <?php if(function_exists('the_views')) { the_views(); } ?>
        <?php endwhile; ?>

    All I want to do is drop some php in there that will alternate the Background color of the class entry, for example, entry1 and entry2 with just different background colors.

    Any help ASAP would be great!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alternate Post BG color’ is closed to new replies.