Hello
I have a custom post type that can be different types:
- Event
- Offer
- Competition
- News
The type of the post is defined by an ACF Radio Button field.
With conditional logic depending on the type selected different ACF fields are showing to fill in per type.
The event posts have a start_date and an end_date Date fields. All the other types have just some text fields.
I have a grid listing page where it shows all the posts. I want to filter out the events that their start_date or their end_date was earlier than today but at the same time include all the other types which don’t have the end_date or start_date fields.
I’ve tried the below:
$query_args = array(
'post_status' => 'publish',
'orderby' => array('title' => 'ASC'),
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1,
'post_type' => 'custom_post',
'orderby' => 'date_added',
'order' => 'desc',
'posts_per_page' => '9',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'start_date',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'start_date',
'compare' => '>',
'value' => date("Y-m-d"),
'type' => 'DATE'
),
array(
'key' => 'end_date',
'compare' => '>',
'value' => date("Y-m-d"),
'type' => 'DATE'
)
)
);
but this returns nothing.
Any ideas?