Home › Forums › Calendar Products › Events Calendar PRO › Search function – how to create a search bar
- This topic has 2 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
November 5, 2015 at 1:10 pm #1022310
Susan Armstrong
ParticipantI have inherited a site that already had The Events Cal Pro version. I am trying to understand the search feature in the calendar. They want a search feature for events but for the life of me I cannot figure out how to get the events to show up on a results page.
I have also added the following common function to my themes function page without success.
// Define what post types to include in search
function include_in_search( $query ) {
if ( $query->is_search ) {
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘tribe_events’ ));
}
return $query;
}
add_filter( ‘the_search_query’, ‘include_in_search’ );I have considered the possibility of the filter bar add-on but I am hesitant to do so.
I have a concern that the initial setup of the calendar is not correct. for example the events slug is not plural and is the same as the single event how will this truly affect the operations? I know I am a bit all over the place but I have spent a lot of time on this. Any insight would be greatly appreciated.November 5, 2015 at 11:18 pm #1022432Brook
ParticipantHowdy armstrongchamberlin,
I would love to help you with this.
I have a concern that the initial setup of the calendar is not correct. for example the events slug is not plural and is the same as the single event how will this truly affect the operations
That is not great. If possible I would change it to be a plural. There are numerous issues that can arise, particularly if one of your event slugs contains something like ‘list’ or ‘map’.
function include_in_search( $query ) {
if ( $query->is_search ) {
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘feed’, ‘tribe_events’ ));
}
return $query;
}
add_filter( ‘the_search_query’, ‘include_in_search’ );It is quite possible that something is overriding your post_type after you set it here. There are so many things that could go wrong I just can’t be of much help telling you why this custom code isn’t working. 🙁 You might need to fire up a debugger like xdebug, then break on the_search_query and see all the code that is affecting it.
Does that all make sense? Please let me know.
Cheers!
– Brook
February 18, 2016 at 8:30 am #1075445Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Search function – how to create a search bar’ is closed to new replies.
