Title: Numeric post classes
Last modified: August 19, 2016

---

# Numeric post classes

 *  [scrambled](https://wordpress.org/support/users/scrambled/)
 * (@scrambled)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/numeric-post-classes/)
 * 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?

Viewing 1 replies (of 1 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/numeric-post-classes/#post-1596640)
 * 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; ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Numeric post classes’ is closed to new replies.

## Tags

 * [classes](https://wordpress.org/support/topic-tag/classes/)
 * [numeric](https://wordpress.org/support/topic-tag/numeric/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/numeric-post-classes/#post-1596640)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
