I am using query_posts to display a list of custom fields from some posts on my WordPress site. Each post has at least one custom field called showcase. In some cases, there are two showcase entries.
I have been able to display more than one showcase from the array, but when ordering the results of the two showcases they are arranged next to each other rather than in order with all the results.
For example. The results come back as - .at/on, 8Bitch, Nightwave, 8cylinder, A Souvenir, A Thousand Details, A Vengeance, ...
The 8Bitch post has two entries in the showcase custom field, one is 8Bitch and the other is Nightwave, but I have been unable to work out how to get Nightwave displayed in order in respect to all of the results.
This is the code I am using at the moment.
<?php $args = array(
'category_name' => 'broadcasts',
'posts_per_page' => -1,
'meta_key' => 'showcase',
'orderby' => 'meta_value',
'order' => 'ASC',
'tag__not_in' => array('2498','123',)
);
query_posts($args);
while (have_posts()) : the_post(); ?>
<?php $featured_artist = get_post_meta( $post->ID, 'showcase', false );
// Let's check if there's any
if( ! empty( $featured_artist ) ) { ?>
<span class='featartist'>
<?php // Check if an array -> has more than one
if( is_array( $featured_artist ) ) {
// Loop through each twitter url
foreach( $featured_artist as $single_featartist ) { ?>
<a href="<?php the_permalink(); ?>"><?php echo $single_featartist; ?></a>, <?php }
}
else { ?>
<?php } ?>
</span>
<?php } ?>
<?php endwhile; ?>
My research led me to believe it can be done with meta_query but I have been unable to work out the correct order for it.
'meta_query' => array(
Any help greatly appreciated. Thankyou.