I need to accomplish the following:
- pull CPT tribe_events
- sort by custom field "pin_to_top" in DESC order
- get posts from today's date & any in the future
- sort remaining posts in ASC order
My goal is to keep any posts with 'pin_to_top' = 1 at the top of the results, then display the remaining results in ASC order by event date.
Here's my query:
$data7 = array (
'post_status' => 'publish',
// create array of arrays
'meta_query' => array(
// pin to top array
array(
'meta_key' => 'pin_to_top',
'meta_type' => 'NUMERIC',
'meta_value_num' => '1',
'compare' => '='
),
// event start date array
array(
'meta_key' => '_EventStartDate',
'meta_type' => 'DATETIME',
'meta_value' => '$today',
'compare' => '>='
),
),
// custom post type
'post_type' =>
array (
'tribe_events' => 'tribe_events'
),
// categories of custom post type
'tribe_events_cat' => 'events',
// sorting
'orderby' => array(
'pin_to_top' => 'DESC',
'_EventStartDate' => 'ASC'
),
);
I am open to suggestions and please keep in mind that I'm just getting started with WP Dev. TIA
pin_to_top
posts and then use the id's of those posts in second query withpost__not_in
parameter?