Home › Forums › Front-end Issues › Display Featured Items First › Reply To: Display Featured Items First
Hi I have tried this for active events, featured is coming first ok but the date orderby is not working (after featured events latest posted events coming next)
// find date time now
$date_now = date('Y-m-d H:i:s');
// query events
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'event',
'meta_query' => array(
'date_clause' => array(
'relation' => 'AND',
array(
'key' => 'start_date',
'compare' => '<=',
'value' => $date_now,
'type' => 'DATETIME'
),
array(
'key' => 'end_date',
'compare' => '>=',
'value' => $date_now,
'type' => 'DATETIME'
)
),
'feature_clause' => array(
'key' => 'featured',
'compare' => 'EXISTS'
)
),
'orderby' => array(
'feature_clause' => 'DESC',
'date_clause' => 'ASC'
)
));
Please help on this (I want to show featured events first next active events based on end date first)
Please help on this
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.