Title: Ordering posts by title problem
Last modified: August 19, 2016

---

# Ordering posts by title problem

 *  [yarray](https://wordpress.org/support/users/yarray/)
 * (@yarray)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/ordering-posts-by-title-problem/)
 * I have a loop on a webpage that orders post titles alphabetically using this 
   code
 * `<?php $side_posts = get_posts('numberposts=-1&$orderby=title&category='.$catVal);?
   >`
 * This will output my posts like this, the problem is i need Track 10,11 to come
   after Track 2,3. HELP thanks
 * the album track 3
    the album track 2 the album track 11 the album track 10 the
   album track 1

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/ordering-posts-by-title-problem/#post-1589516)
 * One way to do this is to use leading zeros in the numbers, like this:
 * the album track 01
    the album track 02 the album track 03 the album track 11 
   the album track 12
 *  Thread Starter [yarray](https://wordpress.org/support/users/yarray/)
 * (@yarray)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/ordering-posts-by-title-problem/#post-1589604)
 * that is a possibility but not an option for my application, i need the numbers
   to stay the same
 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/ordering-posts-by-title-problem/#post-1589759)
 * Try using this before the query_posts:
 *     ```
       function mam_posts_orderby ($orderby) {
          global $mam_global_orderby;
          if ($mam_global_orderby) $orderby = $mam_global_orderby;
          return $orderby;
       }
       add_filter('posts_orderby','mam_posts_orderby');
       $mam_global_orderby = 'reverse(substring_index(reverse(post_title)," ",1))+0 ASC';
       ```
   

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

The topic ‘Ordering posts by title problem’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/ordering-posts-by-title-problem/#post-1589759)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
