can't sort my get_posts query numerically
-
Hi,
I’m trying to make an option panel for a site where all the post titles are numbers. But I can’t figure out how to sort them in numeric order. I’m using get_posts like this:
$rooms = get_posts('category=1&numberposts=200&orderby=title&order=asc'); foreach($rooms as $post) : setup_postdata($post); --> content here endforeach;I’m guessing it’s because the post titles are strings and not numbers. But at the same time I need it to understand letters as well. I could have 6 posts for example and they would have names like:
1
5
12
27d
45
112But I just can’t figure out how to sort them correctly. I’ve tried to put sort($rooms); after the get_posts query, but then it outputs the rooms like this:
1
5
45
12
112
27dI’ve looked everywhere for the answer but I can’t find it. Hope someone can help me!
Thanks!
The topic ‘can't sort my get_posts query numerically’ is closed to new replies.