Title: Add class=first, class=last
Last modified: August 19, 2016

---

# Add class=first, class=last

 *  [valuxes](https://wordpress.org/support/users/valuxes/)
 * (@valuxes)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/add-classfirst-classlast/)
 * I was just wondering if we can have a <li class=”first”> and <li class=”last”
   > in the core to distinguish the first and last post, category, page, etc. in
   a query_posts? It would help a lot in applying different CSS treatments for the
   first and last entry.
 * For example, when I use:
 * >  <?php wp_list_categories(‘show_count=1&title_li=’); ?>
 * the following code is generated:
 * >  <li class=”cat-item cat-item-4″>…
   >  <li class=”cat-item cat-item-11″>… <li 
   > class=”cat-item cat-item-23″>…
 * Instead, could we have the follwing generated:
 * >  <li class=”cat-item cat-item-4 first”>…
   >  <li class=”cat-item cat-item-11″>…
   > <li class=”cat-item cat-item-23 last”>…
 * V

Viewing 1 replies (of 1 total)

 *  [vijayrajesh](https://wordpress.org/support/users/vijayrajesh/)
 * (@vijayrajesh)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/add-classfirst-classlast/#post-836807)
 * were you able to solve it. I need this solution too.

Viewing 1 replies (of 1 total)

The topic ‘Add class=first, class=last’ is closed to new replies.

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 1 reply
 * 2 participants
 * Last reply from: [vijayrajesh](https://wordpress.org/support/users/vijayrajesh/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/add-classfirst-classlast/#post-836807)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
