Title: Shortcode creation &#8211; need loop or if statement?
Last modified: August 20, 2016

---

# Shortcode creation – need loop or if statement?

 *  [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * (@jayseventwo)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/shortcode-creation-need-loop-or-if-statement/)
 * Hi guys, i have created a shortcode for the Twitter Bootstrap carousel, with 
   the following as part of it:
 *     ```
       function j72_carousel_img($atts, $content = null) {
                   return '<div class="item">' . do_shortcode( $content ) . '</div>';
         }
       ```
   
 * What i need is for the above to be looped through so that the first instance 
   of this line has the class “active” added to it like this:
 * `<div class="item active">`
 * This indicates the first image in the carousel – can anyone let me know what 
   needs to be done to achieve this?
 * Thanks

The topic ‘Shortcode creation – need loop or if statement?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [jayseventwo](https://wordpress.org/support/users/jayseventwo/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/shortcode-creation-need-loop-or-if-statement/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
