order – Ordering posts by title containing numbers

Question

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

0
Alessio Baccarini 1 year 2022-01-14T22:53:11-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse