I have a page that lists some custom posts and the they are not showing in the correct Alphabetical order. As a test I have also tried listing them in order of there Ids and that does not appear in the correct order either. When it's listed as Ids they appear as if they grouped into 3 groups high numbers in the 4000s, below 200 and then 3000s, it's very odd. It works fine on my local server. Also ordering works fine in the Wordpress back end. The problem appears to happened when I moved the site to a new hosting package on 1&1. Has any had server specific ordering issues before?
I've made 2 test pages that show a simple list of just titles and IDs (in the wrong order) ID order: http://www.realpatisserie.co.uk/allergen-list/allergen-list-test-id/ title order: http://www.realpatisserie.co.uk/allergen-list/allergen-list-test/
$args = array(
'posts_per_page' => -1, // show all items
'orderby' => 'ID', // was 'title',
'order' => 'ASC',
'post_type' => 'product_al',
'post_status' => 'publish'
);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );
$product_title = ucfirst(get_the_title());
$product_ID = get_the_ID();
?>
<tr id="p_id_<?= $product_ID ?>'">
<td class="title_cell"><?= $product_ID ?></td>
<td class="title_cell"><?= $product_title ?></td>
</tr>
<?php
endforeach;
wp_reset_postdata();
Edit: I tried something a little different and used WP_Query and it does the same thing
$args = array(
'post_type' => 'product_al',
'posts_per_page' => -1,
'orderby' => 'ID',
'order' => 'ASC',
);
$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ) : $the_query->the_post();
$product_title = ucfirst(get_the_title());
$product_ID = get_the_ID();
?>
<tr id="p_id_<?= $product_ID ?>'">
<td class="title_cell"><?= $product_ID ?></td>
<td class="title_cell"><?= $product_title ?></td>
</tr>
<?php
endwhile;
wp_reset_postdata();