I want to make a query_posts where I order first by the number of a custom field (Facebook Likes) and second by date. But I don’t don’t know how.
My query looks like that atm:
$social_query = array(
'meta_key' => 'facebook_likes',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => 10,
'paged' => (int) $paged
);
query_posts( $social_query );
Now the posts get ordered by the number of facebook-likes. This works fine. But if there are posts with the same number of likes they get sortet randomly and thats the problem. If there are posts with the same number of facebook-likes they should be ordered by date.
Can you help me please?
WordPress allows you to specify more than one
orderby
parameter. To do this, you simply separate each parameter with a blank space. Here is how your new query should look like:I’m not sure if this will result in the order that you desire, but that’s what WordPress allows you to do with it’s in-built function.