Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to sort my custom post type in a few different ways using a dropdown.

When I try to sort it as the display_name it doesn't work.

$wp_query = new WP_Query(array('orderby' => 'display_name') );

It works well on a few other sort ways like 'title' 'comment_count' but when I want to sort from the authors real name and not username it doesn't work anymore. Any hint how this can be fixed?

share|improve this question
    
I fixed this issue by adding a new post_meta to my custom_post_type... which added both add_post_meta($post->ID, 'mlp_author', $current_user->first_name . $current_user->last_name); Then sorting by that post_meta using: array('meta_key' => 'mlp_author', 'orderby => 'meta_value') –  murum Mar 18 '13 at 19:38
    
You should add your solution as an answer and "accept" it. –  s_ha_dum Mar 18 '13 at 19:46
    
    
s_ha_dum - I will do that now, but I couldn't do it yesterday because I've to few points. toscho - I think I went through that yesterday when I were searching for an answer but I thought there could be an easier way to fix it. Atleast that wasn't exactly the same way I wanted to do this. –  murum Mar 19 '13 at 15:32

1 Answer 1

I fixed this issue by adding a new post_meta to my custom_post_type... which added both

add_post_meta($postid$current_user->first_name . $current_user->last_name;

Then sorting by that post_meta using:

array('meta_key' => 'mlp_author', 'orderby => 'meta_value')
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.