[wp-hackers] Multiple orderby and order options in WP_Query

Christian Gundersson christian at buro2.se
Tue Apr 5 12:43:58 UTC 2011


Hi!

I have a situation where I want to order a list of post both by author and
date using WP_Query which isn't a problem since 'orderby' lets me do that.
But I want the author part sorted ascending and date part sorted descending.


Any tips on how I can achieve this?

The arguments I pass to WP_Query are:

$author_args = array (
                'post_type'            => 'post',
                'posts_per_page'    => '-1',
                'orderby'            => 'author date',
                'order'                => 'ASC',
                'nopaging'            => true,
                'category_name'        => $category_name
            );

-- 
Regards
//Christian, Büro 2

Büro 2
Skolgatan 5
262 31 Ängelholm
0763-91 55 85
christian at buro2.se


More information about the wp-hackers mailing list