At the time of trying to build a custom query for a sports website which includes the latest result score showing in a loop grip. The below code works for showing posts that are equal to or past today’s date which is OK. But it is required to only show if a ACF custom field check box called show_result
is checked in that specific post.
So basically if the “show_result” checkbox is ticked for that post in the back end then the loop grid in Elementor will only show the past posts with this checkbox checked.
Is it possible to modify the code below to include the above conditions?
add_action('elementor/query/latest_result', function($query){
$query->set('orderby', 'meta_value');
$query->set('order', 'DESC');
$meta_query[] = [
'relation' => 'AND',
[
'key' => 'match_date',
'value' => date('Y-m-d'),
'compare' => '<=',
'type' => 'DATE'
],
];
$query->set( 'meta_query', $meta_query );
});
Tried varying code with nothing working.
The following condition is required in your meta query to address if checkbox is marked (value will be 1).
[
'key' => 'show_result',
'value' => '1',
'compare' => '=',
'type' => 'NUMERIC'
]
2