mrtakdnz
mrtakdnz

Reputation: 149

sort post with title and custom field on wordpress

i need to sort my post by title asc, and sort my posts by custom value desc

i try to do this but i failed:

<?php $the_query = new WP_Query( array('category_name' => 'ref-ckck',
                                                'posts_per_page' => -1,
                                                'order' => 'asc',
                                                'orderby' => 'title',
                                                'order' => 'desc',
                                                'orderby' => meta_key,
                                                'meta_key' => 'durumu'
                                                ) ); ?>

i need to order my post by title asc and order it by durumu meta key desc.

i dont use MySQL in wordpress either.

thanks in advance...

Upvotes: 0

Views: 775

Answers (1)

bingjie2680
bingjie2680

Reputation: 7773

I think the meta_key should be meta_value like

'orderby' => 'meta_value',

whose meta_key is corresponsding to 'durumu'.

Upvotes: 0

Related Questions