I am 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 todays date which is ok. But I want it to include to only show if a ACF custom field check box called "show_result" is checked in that specific post.
So bassically 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 that?????
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 );
});
Any help will be much appreciated?
Thank you
Tried varying code with nothing working.
2
Answers
Unfortunately when I have tried to add your code to the code snippet I had it hasn’t worked? The loop is disappearing when putting the query name in the element or loop grid query id box
});
The following condition is required in your meta query to address if checkbox is marked (value will be 1).