Issue Description
When looking at IDF, the request came in to use ajax filtering, and order events by the event date descending, i.e. Future > Present > Past
Tweaking the archive page is straight forward enough;
Using the exact same code in the ajax function wasn’t working – it was ordering by post date.
Much tearing of hair out. Much googling.
Enter: suppress_filters
Code Snippets
$events_args = array(
'post_type'=>'cpt_events',
'orderby'=>'meta_value',
'order'=>'DESC',
'meta_key'=>'event_date',
);
Fixed Code Snippets
$events_args = array(
'post_type'=>'cpt_events',
'post_status'=>'publish',
'orderby'=>'meta_value',
'order'=>'DESC',
'meta_key'=>'event_date',
'suppress_filters'=>true
);
References
Reference Description |
Reference Link |
---|---|
Conversation on stackoverflow |
View Page |