This question already has an answer here:
- wp_query order by title 1 answer
I am using the post to display attorney verdicts and case details. The post title is the verdict amount entered as a string. (no $ "," or ".")
I am formatting the title using PHP number format:
EX: User enters 360137 in the post title. $number = get_the_title(); $ammount = number_format($number); echo '<h1>$'. $ammount . '</h3>'; Returns $360,137
This is working as expected.
Using get_posts() I can 'orderby' => 'title' and 'order' => 'DESC' or 'ASC'
$args = array( 'category' => 64, 'orderby' => 'title', 'order' => 'DESC' ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post );
While this is working it does not recognize the length of the value. For example it will display 30,000 before 2,100,000. How do I get this list sorted by ASC or DESC AND by string length?
I want to show the largest verdicts first.