order – Ordering posts by title containing numbers
I’m looking for help using the posts_orderby hook in wordpress.
Please forgive the low level of abstraction, but I really need quick help on this.
I have custom type posts whose titles are made up of a fixed 8-character text string (TM.74.G.) followed by numbers ranging from 358 to above 1000 (and that’s the order I need them to follow). As expected, sorting in ASC returns a post order which starts from 1000 (titles are not processed as integers); if I apply a filter like this
function orderby_post_title_int( $orderby )
{ return ‘(wp_posts.post_title+0) ASC’; }
results are unclear.
Any hint on this? Thank in advance, Alessio
Leave an answer