The user starts at a page showing posts of custom post type, "agent".
Each post displayed shows a region/custom taxonomy it belongs to and links to a page that shows all posts in the region the user clicked.
This is how these posts are currently displayed,
<?php while ( have_posts() ) : the_post(); ?>
Ideally I'd like to to sort these alphabetically by meta_key lname rather than by post date which appears to be the wordpress default.
Thanks for any input
Edit: Script I use to get all custom post type Agents. Puts one specified post as last post.
<?php
$loop = new WP_Query( array(
'post_type' => 'agents',
'orderby' => 'meta_value',
'meta_key' => 'lname',
'order'=>'ASC',
'meta_query' => array(array( 'key' => 'lname' )),
'post__not_in' => array( '93' ),
'posts_per_page' => -1 ) );
$loop2 = new WP_Query( array(
'post_type' => 'agents',
'post__in' => array( '93' ) ) );
?>
<?php
if($loop->have_posts() || $loop2->have_posts()) {
if($loop->have_posts()) { while($loop->have_posts()) { $loop->the_post();
?>