This support ticket is created 5 years, 4 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.
Yes! This solved the main problem, they are there and now I can manage those fields.
I still have some issue.
I can display _start_date_picker filed by this shortcode:
[wpv-post-field name='_start_date_picker']
But it seems I cannot change the date format as I can do with a Toolset Date field. How can I manage it?
I also tested the date filter, I can set it up, I also set date_format to Y-m-d (the current data format of _start_date_picker), but the search result is "No items found". I also try setting the Query filter to "like", but it still doesn't get any result.
Hello. Thank you for contacting the Toolset support.
I would like to know how you want to filter the view results by date. Do you want to display all the results that are less than the selected date or you want to apply "equal to" the selected date?
I'm inetrested in this options:
Any date
Today
This weekend
This week
Next week
This Month
Pick a date
So the "equal to" is ok for the Pisck a date (maybe I can also split the select and add the calendar icon with date picker outside), but then I'd like to create the other options too.
I've added following code to Toolset Settings "Custom Code" section:
add_filter('wpv_filter_query', 'func_filter_events_by_date', 10, 3);
function func_filter_events_by_date($query_args, $view_settings, $view_id) {
global $WP_Views;
global $wpdb;
if($view_id == 675) {
$start = $_GET['wpv-_start_date_picker'];
$end = $_GET['wpv-_start_date_picker']+(24*3600);
$field_name = '_start_date_picker'; // replace your field name
$sql = "SELECT post_id FROM ".$wpdb->prefix."postmeta,".$wpdb->prefix."posts
WHERE (".$wpdb->prefix."postmeta.post_id = ".$wpdb->prefix."posts.ID)
AND ((".$wpdb->prefix."postmeta.meta_key = '".$field_name."'
AND CAST(UNIX_TIMESTAMP(".$wpdb->prefix."postmeta.meta_value) AS SIGNED) BETWEEN '".$start."' AND '".$end."'))
AND ".$wpdb->prefix."posts.post_type = '".$query_args['post_type'][0]."'
AND ((".$wpdb->prefix."posts.post_status = 'publish' OR ".$wpdb->prefix."posts.post_status = 'private'))";
$res = $wpdb->get_col($sql);
if(!empty($res)){
$query_args['post__in'] = $res;
}
}
return $query_args;
}
I can see its filtering the correct results based on the selected date:
=> hidden link
Well - you need to add a dropdown select box within the "search and pagination" section which have the options you required. You need to calculate the time for your each option and based on the selected option you need to adjust your views query which I already wrote for you.
I made a try adding a new "between" filter for _start_date (I set the filter output to "display:none"), then I've created some shortcodes to display "today date", "tomorrow date" and "next 7 days" and finally I've added this select:
Sorry to say this, this may be the thing which you do not like but I (we) need to work within the predefined support boundary.
This needs custom programming which is beyond the scope of our support policy. I already show you a way how to do this and shared the hints but we can not do custom programming for your custom requirements.
I hope I made my point clear and its simple to understand, If you need custom programming for your project, please feel free to contact our certified partners. They will be happy to help you with your any custom programming needs:
=> https://toolset.com/contractors/
Don't worry, I understand it, you gave me a great help. Just one more question to understand if I'm on the right way.
Should I replicate your code, edit $start and $end variables to make the job?
I've another issue with the Map location filter. I want to add a distance filter, but it doesn't get the YITH non-Types field _direction_event, even if it is alredy managed by Types. How can I do it?
I know it's a different issue, but I would like you split again the topic, I'd like to follow with you because you already know the project and you already have full the access to it.
Should I replicate your code, edit $start and $end variables to make the job?
=> Yes, and if needed you need to modify the query but its totally depends on your requirement and how you pass the data.
I've another issue with the Map location filter. I want to add a distance filter, but it doesn't get the YITH non-Types field _direction_event, even if it is alredy managed by Types. How can I do it?
I know it's a different issue, but I would like you split again the topic, I'd like to follow with you because you already know the project and you already have full the access to it.
==> I understand and I respect your intention to work with me. I kindly urge you to create a new ticket and feel free to assign it to me. As I'm about to end the shift today. I will take care of your ticket tomorrow.