Title: Reverse order shortcode
Last modified: September 1, 2016

---

# Reverse order shortcode

 *  Resolved [outhands](https://wordpress.org/support/users/outhands/)
 * (@outhands)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/)
 * Hi,
 * Wanted to reverse the order of a shortcode, does anyone know what the default
   order is within this function? And is there a way to reverse the order inside
   this function?
 * **Example now:**
    1 2 3 4 5 6
 * **Wanted result**
    6 5 4 3 2 1
 *     ```
       add_shortcode( 'pers', function ( $atts, $content=NULL ) {
             extract(shortcode_atts(array(
                 'position'  => '',
                 'content'   => ''
             ), $atts ) );
   
             return esc_attr($position) . ': ' . esc_attr($content);
       });
   
       // Example usage:
       // [pers position="1" content="something here"]
       ```
   
 * Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/#post-7591929)
 * There’s nothing in that shortcode to reverse.
 * Forget about the code for a minute and explain what you’re trying to accomplish.
 *  Thread Starter [outhands](https://wordpress.org/support/users/outhands/)
 * (@outhands)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/#post-7591940)
 * [@sterndata](https://wordpress.org/support/users/sterndata/),
 * Thank you for your reply, we have build a sort of press release numbered from
   1-9 where 9 should be the first one. Thought about it to just save it reversed
   so it’s set already but if there is a much easier way I would love to hear it
   from you.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/#post-7591942)
 * Do you use multiple shortcodes with different positions in the content or are
   you using this in another way?
 * I think saving it in reversed order is the easiest way.
 *  Thread Starter [outhands](https://wordpress.org/support/users/outhands/)
 * (@outhands)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/#post-7591943)
 * [@keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Each content has it’s own position, so `[pers position="1" content="something
   here"]` and `[pers position="2" content="something else here"]` agree about saving
   it reversed is the easiest way to do this.
 * Thank you!
 * **EDIT:**
    Solved this issue by saving it reversed into the database query. For
   this I have used the PHP function: [array_reverse();](http://php.net/manual/en/function.array-reverse.php)

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Reverse order shortcode’ is closed to new replies.

## Tags

 * [add_shortcode](https://wordpress.org/support/topic-tag/add_shortcode/)
 * [descending](https://wordpress.org/support/topic-tag/descending/)
 * [function](https://wordpress.org/support/topic-tag/function/)
 * [reverse](https://wordpress.org/support/topic-tag/reverse/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [outhands](https://wordpress.org/support/users/outhands/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/reverse-order-shortcode/#post-7591943)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
