davecc
Member
Posted 8 months ago #
$args = array(
'meta_query' => array(
array(
'key' => 'event_date',
'value' => $today,
'compare' => '<='
)
),
'post_type' => 'post',
'meta_key' => 'event_date',
'orderby' => 'meta_value',
'order' => 'DESC'
);
This works fine for ordering by 1 custom field, how can I add a second order by a custom field.
You're on the right track. Just add a second array to your meta_array.
http://www.wpmods.com/use-meta_query-query-posts-postmeta/
http://scribu.net/wordpress/advanced-metadata-queries.html
http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
array(
'key' => 'event_date',
'value' => $today,
'compare' => '<='
),
array(
'key' => 'SECOND KEY',
'value' => SECOND VALUE,
'compare' => 'COMPARISON VALUE'
)
davecc
Member
Posted 7 months ago #
Hi Nate, I've tried that, but when I do that, it only shows posts that specifically match both meta_arrays.
All my posts have even dates, but some of them are also "top events", so I want to sort all the posts by date and by top post, does that make sense?
Any advice would be greatly appreciated.
davecc
Member
Posted 7 months ago #