• 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)
  • 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

    (@yarray)

    that is a possibility but not an option for my application, i need the numbers to stay the same

    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.