Right, this is annoying as anything.
Client’s site, they sell cars. I’m using ACF for the listings in a custom post type.
Trying to do a simple alphabetical re-ordering of the cars (default is by date posted).
Works fine in A-Z and Z-A… except the results have P and R in the wrong places (ie, in A-Z, Porsche appears after Range Rover, and in Z-A it appears before).
Absolutely bemused. Unless the order of the alphabet changed and nobody mentioned it to me.
Code:
<?php
// query
$the_query = new WP_Query(array(
'post_type' => 'carsales',
'posts_per_page' => -1,
'meta_key' => 'car_make',
'orderby' => 'meta_value',
'order' => 'DESC'
));
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
<!-- DOES STUFF TO SHOW THE RESULTS, WHICH WORKS AND IS LENGTHY, SO REMOVED IT -->
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Anybody any ideas? Thanks in anticipation.
Ross
Does not make any sense to me at all. I would say that there is some invisible character in there but that would make the results more odd than what you’re seeing.
The only other thing I can think of is that there’s another filter being applied that you might be unaware of. I would try displaying all of the query after it’s run to see if there’s any arguments that should not be there.
$the_query = new WP_Query(array(
'post_type' => 'carsales',
'posts_per_page' => -1,
'meta_key' => 'car_make',
'orderby' => 'meta_value',
'order' => 'DESC'
));
echo '<pre>'; print_r($the_query); echo '</pre>';