This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Initialize a view with posts that match todays date with the ability to change the search criteria (date picker) to another day in the future.
The view however shows all posts from today and forward when first visiting the page.
After selecting another date the view only shows the selected posts with the matching date which is correct.
How can I initalize a view that match only today() on the first visit and then be able to select another date in the future?
Hello. Thank you for contacting the Toolset support.
To display the posts based on current date by default, you will have to use the view's filter hook: wpv_filter_query.
When you say you want to display posts from today's date by default, do you mean that you want display posts having date grater than equal to current time and before the end of date hour 12:59:59?
- If yes, can you please share problem URL and admin access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
As I do not have FTP access or even Toolset offers "Custom Code" section where we can add the code snippets but when I try to create code snippet it seems on server there is no rights:
- hidden link
I've installed and activated the "Code Snippet" plug9in and I've added the following view's filter code to the "Code Snippet" plugin's snippet:
=> hidden link
add_filter( 'wpv_filter_query', 'func_filter_custom_date_with_fulldaytime', 99, 3 );
function func_filter_custom_date_with_fulldaytime( $view_args, $settings, $view_id ) {
if ( $view_id == 12888) {
if (!isset($_REQUEST['search']) ) {
$target_field = "wpcf-session_showtypestimestamp"; // change this field slug to your field slug
foreach ($view_args['meta_query'] as $key => $value):
if ($value['key'] == $target_field){
$day_start_time = $value['value'];
$day_end_time = strtotime('+1 day', $day_start_time ) - 1;
$filer_index = $key;
break;
}
endforeach;
if (isset($filer_index)){
$view_args['meta_query'][$filer_index] = array('key' => $target_field,
'value' => array($day_start_time, $day_end_time),
'type' => 'NUMERIC',
'compare' => 'BETWEEN' );
}
}
}
return $view_args;
}
Can you please confirm you can see today's posts by default:
- hidden link