PHP Loop and CSS class to looped item

jporter80
jporter80 used Ask the Experts™
on
Okay this will probably be really simple to somebody.  but here is my wordpress loop:

<?php $my_query = new WP_Query('cat=1&orderby=date&order=desc&showposts=4'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $post_image = get_post_meta($post->ID, 'featured_960_335',$single=true); ?>
		 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img height="335" width="960" class="feature_image" src="/wp-content/themes/bethel/lib/scripts/thumb.php?src=<?php echo $post_image ?>&amp;w=960&amp;h=335&amp;zc=1&amp;q=100" alt="<?php the_title(); ?>"/></a>
        <?php endwhile; ?>

Open in new window


basically i want to add a css class to the the <a> like <a class="slide-1"> so each slide would be numbered by adding one to each loop.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Don't talk to me.
Commented:
Something like this?

<?php 
$my_query = new WP_Query('cat=1&orderby=date&order=desc&showposts=4'); 
$x = 0;
while ($my_query->have_posts()) : $my_query->the_post(); 
$x++;
$do_not_duplicate = $post->ID; 
$post_image = get_post_meta($post->ID, 'featured_960_335',$single=true); 
?>
		 <a class="slide-<?php echo $x; ?>" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><img height="335" width="960" class="feature_image" src="/wp-content/themes/bethel/lib/scripts/thumb.php?src=<?php echo $post_image ?>&amp;w=960&amp;h=335&amp;zc=1&amp;q=100" alt="<?php the_title(); ?>"/></a>
        <?php endwhile; ?>

Open in new window

Author

Commented:
yup that worked

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial