The front facing of the view is: lien caché
The edit of the view is: lien caché
The view correctly shows only the past events, but say I choose May 14th 2023 which is an event date, the results don't actually match that date.
This is also true for the future view. Thank You and let me know if you need more info.
Hi, I'm just following up on this.
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
When I search for 15th May, 2023 then I can see the past event of may 14th. Is that Ok with you?
Please check the following:
- lien caché
Otherwise we will require to add another 24 hours to the event date so that it can search the event.
Thank You, but on my end now the date field just refreshes the results and doesn't actually change them.
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
Do you mean you selected the difference date and it just show the different selected date and does not refresh the view result? if this is correct then you will have to click on search button to apply the different date.
I am clicking search. Minesh, we keep going round and round here. Are we close to a solution yet?
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
Here is the video and I can see when I select the 14th may it shows two results and when I select 15th may it shows three results.
=> lien caché
Am I missing anything here?
So it appears you've made it so that the date filter works to show only events before that date. That is not what we need. We need the view to control the past/future, but the date field to be a match for that date.
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
Can you please check now, I've selected the July 15th 2023 and it shows that event only:
- lien caché
I've adjusted the code added to "Custom Code" section as given under:
add_filter( 'wpv_filter_query', 'func_filer_show_past_events', 99, 3 );
function func_filer_show_past_events( $query_args, $view_settings, $view_id ) {
if( $view_id == 4224 and !isset($_GET['wpv_view_count'])) {
$args = array(
'relation' => 'AND',
array(
'key' => 'wpcf-date-ce',
'value' => strtotime('23:59:59'),
'compare' => "<",
'type' => 'numeric'
),
);
// add these arguments to your meta query
$query_args['meta_query'] = isset($query_args['meta_query']) ? $query_args['meta_query'] : [];
$query_args['meta_query'][] = $args;
}else{
if(isset($_GET['wpv-wpcf-date-ce']) and !empty($_GET['wpv-wpcf-date-ce']) and
is_numeric($_GET['wpv-wpcf-date-ce']) and $_GET['wpv-wpcf-date-ce']>0) {
$meta = $query_args['meta_query'];
foreach($meta as $k=>$v):
if($v['key'] == 'wpcf-date-ce'){
$filter_array = array(
'relation' => 'AND',
array(
'key' => 'wpcf-date-ce',
'value' => $_GET['wpv-wpcf-date-ce'],
'compare' => ">=",
'type' => 'numeric'
),
array(
'key' => 'wpcf-date-ce',
'value' => $_GET['wpv-wpcf-date-ce']+86400-1,
'compare' => "<=",
'type' => 'numeric'
));
$query_args['meta_query'][] = $filter_array;
unset($query_args['meta_query'][$k]);
break;
}
endforeach;
}
}
return $query_args;
}
add_filter( 'wpv_filter_query', 'func_filer_show_future_events', 99, 3 );
function func_filer_show_future_events( $query_args, $view_settings, $view_id ) {
if( $view_id == 4288 and !isset($_GET['wpv_view_count'])) {
$args = array(
'relation' => 'AND',
array(
'key' => 'wpcf-date-ce',
'value' => strtotime('23:59:59'),
'compare' => ">",
'type' => 'numeric'
)
);
// add these arguments to your meta query
$query_args['meta_query'] = isset($query_args['meta_query']) ? $query_args['meta_query'] : [];
$query_args['meta_query'][] = $args;
} else{
if(isset($_GET['wpv-wpcf-date-ce']) and !empty($_GET['wpv-wpcf-date-ce']) and
is_numeric($_GET['wpv-wpcf-date-ce']) and $_GET['wpv-wpcf-date-ce']>0) {
$meta = $query_args['meta_query'];
foreach($meta as $k=>$v):
if($v['key'] == 'wpcf-date-ce'){
$filter_array = array(
'relation' => 'AND',
array(
'key' => 'wpcf-date-ce',
'value' => $_GET['wpv-wpcf-date-ce'],
'compare' => ">=",
'type' => 'numeric'
),
array(
'key' => 'wpcf-date-ce',
'value' => $_GET['wpv-wpcf-date-ce']+86400-1,
'compare' => "<=",
'type' => 'numeric'
));
$query_args['meta_query'][] = $filter_array;
unset($query_args['meta_query'][$k]);
break;
}
endforeach;
}
}
return $query_args;
}
Thank You, but this view is the past view and now it's only showing the future. The date field does work correctly now though.
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
There was a typo and I've fixed that and now it will show the past events. Can you please confirm it works as expected now.
Minesh, I think you are working on the wrong view. You did the work on lien caché based on that last link you sent.
When I requested the view to be worked on was: lien caché
Please make sure to re-read my private message with the links. We are working on one past view and one future view.
There are 3 views total.
Original(view name "community-events" id=2545): lien caché (should not have been touched)
Past (view name "community-events-past" id=4224): lien caché
Future (view name "community-events-future" id=4288): No front facing page yet. Can build one if needed.
But you are working on lien caché (view name "events" id=104) based on the last link you sent me, though the view ID in the snippet is correct. Which is a view completely separate from all the other 3 views and uses a completely different post type. This should not have been touched. You may have just sent the wrong link. Not sure.
Thank You and please let me know if you need more detail.
Minesh
Supporter
Les langues:
Anglais (English )
Fuseau horaire:
Asia/Kolkata (GMT+05:30)
The code I shared as you already noticed that its applied to your view IDs:
- Past (view name "community-events-past" id=4224): lien caché
and
- Future (view name "community-events-future" id=4288): No front facing page yet. Can build one if needed.
I just checked with the past view and when I search for 14th May 2023, it shows the correct results:
- lien caché
You can also verify for future view as well.
Both past and future work better now. But when I select any other filter i.e. the vendor fee, the view becomes future and past again.
I hope you are having a great day. Any updates on this?