Home › Forums › Calendar Products › Filter Bar › Event Search Bar date function
- This topic has 10 replies, 4 voices, and was last updated 7 years, 5 months ago by Derek.
-
AuthorPosts
-
October 21, 2016 at 8:52 am #1180608DerekParticipant
Hi,
When using the classic search bar to search by date it appears to be searching for any date after the date I search. Where/how can I customize it so it only searches for the date entered?
Thanks for your help,
DerekOctober 24, 2016 at 1:13 pm #1182102NicoMemberHi there Derek,
Thanks for reaching out to us! I can help you here š
The date range that will be shown after searching for a specific date will depend in the view you are currently in. For example, if you are in day view (only shows events of the day) then this will work as you describe, but if you are in month view, all the month will be shown.
Are you trying to change this for list view? If that’s the case maybe I can craft a snippet to adjust the time period to just one day.
Please let me know about it,
Best,
NicoOctober 24, 2016 at 6:31 pm #1182225DerekParticipantHi Nico,
I am in photo view.
Thank you for your help!
DerekOctober 24, 2016 at 6:46 pm #1182234DerekParticipantMore details to make sure I’m clear, I am hosting an event that takes place April 1st-8th. I’d like when a person searches the calendar for a single day they only see events from that date.
I am using community events and the filter bar as well.
Thank you again!
DerekOctober 25, 2016 at 6:42 pm #1182914NicoMemberThanks for clarifying Derek!
One more thing before I give this snippet a try: if no date is selected do you still want to limit the events shown to the current day? Or do you want this limit to take effect when a date is selected in the picker?
Please let me know about it,
Best,
NicoOctober 25, 2016 at 9:41 pm #1182980DerekParticipantThanks Nico!
I only want to filter the calendar to a specific date if the user selects a date to search by. The calendar would show all events by default and a user could filter it to a single day using the date picker.
Thanks for your help!
October 28, 2016 at 8:11 am #1184418NicoMemberThanks for the patience while I worked on this Derek!
Please try pasting the following code in your theme’s (or child theme’s) functions.php file:
/* Tribe, limit tribe bar date search to one day */
add_action( 'tribe_events_pre_get_posts', function( $query ) {
$ajax_or_main = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) || $query->is_main_query();if ( ! $ajax_or_main || empty( $_REQUEST['tribe-bar-date'] ) ) {
return;
}if ( ! preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $_REQUEST['tribe-bar-date'], $matches ) ) {
return;
}$end_date = date('Y-m-d', strtotime( $matches[0] . ' +1 day') );
$query->set( 'end_date', $end_date);
} );
Please let me know if it works for you,
Best,
NicoOctober 28, 2016 at 8:33 am #1184430DerekParticipantNico,
It looks like that worked!
Thank you so much for your help on this.
Would you be able to help on another issue?
I’d like to change the bootstrap-datepicker.js to only show the month of April as well as change startDate and endDate to April 1st-8th. So they user only sees April and only has the option to select April 1st-8th when searching/creating an event.
Thank you again,
DerekOctober 31, 2016 at 8:28 pm #1185600NicoMemberThanks for following up Derek!
Iād like to change the bootstrap-datepicker.js to only show the month of April as well as change startDate and endDate to April 1st-8th. So they user only sees April and only has the option to select April 1st-8th when searching/creating an event.
Well, I’m not sure how to do this I’d say you’ll need to take a look at the Bootstrap Datepicker documentation to see if that can be set and how. Once you got that you can ‘remove’ the date picker from the field, change the options and re-add it to the field. This reply shows how to do so ā
https://theeventscalendar.com/support/forums/topic/some-problems-with-events-calendar-pro-new-user/#dl_post-1127004Please let me know if that helps,
Best,
NicoNovember 22, 2016 at 8:35 am #1195915Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Event Search Bar date function’ is closed to new replies.