Sort WP custom posts by meta value
-
Hi I need to sort custom posts by meta value but I need this value to be sorted alphabetically. Meta value that I want it to be sorted is Speakers. This is the snippet that works fine. I need this key value sorted alphabetically
<?php $args = array( 'post_type' => 'talk', 'post_status' => 'publish', 'posts_per_page' => -1, 'meta_key' => '_my_meta_value_key', 'orderby' => 'title meta_value', 'order' => 'ASC' ); query_posts( $args ); while ( have_posts() ) : the_post();?> <?php $custom_fields = get_post_custom(); $meta_speaker = get_post_meta($post->ID, '_my_meta_value_key', false); ksort($meta_speaker); foreach($meta_speaker as $meta) { $speaker = get_the_title($meta); echo '<td>'.$speaker.'</td>'; } ?>The actual url is thenines.tv/test-2 . The column called Speaker Name is where I need this to be sorted alphabetically.
Thanks in advance.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Sort WP custom posts by meta value’ is closed to new replies.