WordPress.org

Ready to get started?Download WordPress

Forums

Numeric post classes (2 posts)

  1. scrambled
    Member
    Posted 4 years ago #

    I want to display four posts, but I need each to have a numeric class. That's to say, I want a 1, 2, 3, or 4 where "n" is below.

    <?php query_posts('showposts=4&cat=6');?>
    
    <?php while ( have_posts() ) : the_post() ?>
    
    <li><a href="#" class="n"><img src="<?php echo get_post_meta($post->ID, "wppt_preset2", true); ?>"></a></li>
    
    <?php endwhile; ?>

    Ideas?

  2. alchymyth
    Forum Moderator
    Posted 4 years ago #

    do you mean:

    <?php query_posts('showposts=4&cat=6');?>
    <?php $counter = 1; ?>
    <?php while ( have_posts() ) : the_post() ?>
    
    <li><a href="#" class="<?php echo $counter; $counter++; ?>"><img src="<?php echo get_post_meta($post->ID, "wppt_preset2", true); ?>"></a></li>
    
    <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic