WordPress orderby Alphabetical order only partially working

I have ordered a custom post type loop by a custom field of last_name. It does order some of the list by last name alphabetically, however in the middle of the list is it goes out of alphabetical order, and then appears to go back in alphabetical order

My code is as follows:

Read More
 <?php $loop = new WP_Query(array( 'post_type' => 'engineer',
   'posts_per_page' =>-1,'order_by' => array('last_name'), 'order' => 'ASC')); 
    $count =0;?>


 <?php if ( $loop ) : while ( $loop->have_posts() ) : $loop->the_post(); ?>


 <li class="portfolio-item <?php echo strtolower($tax); ?> all">

 <ul class="pe_list_row">
 <li class="eid">
 <?php echo get_post_meta($post->ID, 'Engineer Id  Number', true); ?>
 </li>
 <li class="edis">
 <?php echo get_post_meta($post->ID, 'Discipline', true); ?>
  </li><li class="lname">
 <?php echo get_post_meta($post->ID, 'Last Name', true); ?>
</li><li class="fname">
<?php echo get_post_meta($post->ID, 'First Name', true); ?>
</li>


</ul>

</li>

<?php endwhile; else: ?>

<?php endif; ?>

P.S. I have stripped out some other code on the page the deals with taxonomy tags being placed in the list items class attribute. That code involved getting tags with get_terms and counting then with the count method, to then iterate though to produce the filter navigation. This code is being used with the filterable.js library.

The page is this.

Related posts

Leave a Reply

1 comment