Hi Matthew,
Thank you for waiting, while I performed some research and testing around your requirements.
Before moving on to the possible solutions, one important point to remember is that the way custom field query works in WordPress, a "non-existent custom field" record is not the same as the blank or a "0" value.
What this means is that if you're planning to apply some filter to the custom field with key "wpcf-end-date", it is important that an empty or a 0 valued record exists with that key against all your posts. Any post which won't have any custom field record with that key will simply be ignored by that query.
First, a simpler approach. Since you're pulling/syncing data from a feed, you can explore if a rule can be set to assign a fixed end date from the far future for all the posts which don't have any actual end date. This way simple date filter with "End date value greater than or equal to TODAY" will do the job.
If setting a far future date is not possible, you'll need to create 3 views.
1. The first view will be set to get all posts where "Advertiser ID" is equal to the shortcode attribute "retailerid" and the End Date is equal to an empty constant.
Example screenshot: hidden link
2. The second view will be set to get all posts where "Advertiser ID" is equal to the shortcode attribute "retailerid" and the End Date is greater than or equal to TODAY.
Example screenshot: hidden link
Important note: Please make sure that both these views only return the IDs of the posts in an array format, which will then be called in a PHP function, for the third view
3. The third view will be set to show all posts without any filter but using the "wpv_filter_query" filter, it will be made to call in only posts, whose IDs are included in the output of the first and the second view.
( ref: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query )
Example snippet:
add_filter( 'wpv_filter_query', 'show_combined_posts_fn', 1000 , 3 );
function show_combined_posts_fn( $view_args, $view_settings, $view_id ) {
if ( ( !is_admin() && isset($view_settings['view_id'] ) ) && ( ($view_settings['view_id'] == XYZ) ) )
{
$IDs_from_view_1 = array("1", "2");
$IDs_from_view_2 = array("3", "4", "5", "6");
$view_args['post_in'] = array_merge($IDs_from_view_1, $IDs_from_view_2);
}
return $view_args;
}
Please replace "XYZ" with the actual ID of the third view and the "$IDs_from_view_1" and "$IDs_from_view_2" will hold the IDs from the first and the second view, using the "render_view" function.
https://toolset.com/documentation/programmer-reference/views-api/#render_view
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar