I hope someone can help me with this. I have been reading other posts, the Codex, and trying others code, but can't fix my query.
I am creating a Page that contains a list of authors. The authors are in two categories, and I need to sort by last name, first name. I want to sort them by the custom field wpcf-sortname (from the Types plugin).
I get the correct results from the query, but the results are sorted by ID.
Note: I'm not very good with queries, but any help will be appreciated.
I've tried:
<?php query_posts(array('category__and'=>array(48,49),'meta_key'=>wpcf-sortname,'orderby'=>meta_value,'order'=>ASC,));
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" class="participants"><?php the_title(); ?></a><br />
<?php endwhile; // end of the loop. ?>
And:
<?php
$args = array( 'category__and'=>array(48,49),'meta_key'=>wpcf-sortname,'orderby'=>wpcf-sortname,'order'=>ASC,'posts_per_page'=>-1);
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<div>
<a href="<?php the_permalink() ?>" class="participants" style="color:red"><?php the_title(); ?></a><br />
</div>