Home › Forums › Calendar Products › Events Calendar PRO › Add Category to Search Bar
- This topic has 5 replies, 4 voices, and was last updated 7 years, 6 months ago by Felix.
-
AuthorPosts
-
November 7, 2016 at 4:51 am #1188546FelixParticipant
Hi,
I need to have a drop-down with all categories in the regular search bar. I know it can be added as a filter, but that would produce the extra box and make the search more complex than needed.
How can I add it as a regular field? I have prepared this so far:
add_filter( 'tribe-events-bar-filters', 'tribe_events_add_category', 1, 1 ); function tribe_events_add_category( $filters ) { $filters['tribe-bar-category'] = array( 'name' => 'tribe-bar-category', 'caption' => 'Category', 'html' => '' ); return $filters; }
I hope you can help.
Thanks in advance,
FelixNovember 7, 2016 at 6:28 pm #1188902GeorgeParticipantThis reply is private.
November 9, 2016 at 2:02 am #1189517hildesheimerallgemeineParticipantHello, I got the same problem. I want to put a category drop down into the searchbar. Can you help me?
November 9, 2016 at 2:07 am #1189518FelixParticipantHi,
I managed to integrate a solution, but it only seems to work properly with the “Filter Bar” Plugin active on the page. Please feel free to post a better solution.
add_filter( 'tribe-events-bar-filters', 'tribe_events_add_category_filter', 1, 1 ); function tribe_events_add_category_filter( $filters ) { $args = array( 'show_option_all' => esc_html__( "All", "the-events-calendar" ), 'show_option_none' => '', 'option_none_value' => '-1', 'orderby' => 'ID', 'order' => 'ASC', 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'include' => '', 'echo' => 0, 'selected' => '-1', 'hierarchical' => 0, 'name' => 'tribe_eventcategory', 'id' => '', 'class' => '', 'depth' => 0, 'tab_index' => 0, 'taxonomy' => 'tribe_events_cat', 'hide_if_empty' => false, 'value_field' => 'term_id', ); $html = wp_dropdown_categories( $args ); $filters['tribe-bar-category'] = array( 'name' => 'tribe-bar-category', 'caption' => esc_html__( 'Category', 'the-events-calendar' ), 'html' => $html ); return $filters; }
November 9, 2016 at 3:45 am #1189531GeorgeParticipantHey Deltex,
I wrote this above to Felix, so will post it here as well:
We unfortunately cannot provide any assistance with writing custom code, which would be required to pull off what you describe. Our Filter Bar add-on indeed offers the Category filter (which you can choose a few different display options for, by the way, so it doesn’t have to be a big complex checkbox system and can be a simple one-level dropdown instead).
Other than our Filter Bar add-on, you would have to manually code all of this filter yourself and/or hire a professional developer for assistance. We have a list of great developers here → http://m.tri.be/18k1 (and we have no affiliation with any of these folks–they’re simply some well-respected names in the community that we’ve compiled).
☝️ I’m sorry to bear this news, but perhaps the code Felix suggested helps.
I wish you both the best of luck with these customizations. Open a new thread any time if other issues or questions arise.
Cheers,
George -
AuthorPosts
- The topic ‘Add Category to Search Bar’ is closed to new replies.