Home › Forums › Calendar Products › Filter Bar › Adding Custom Taxonomy to Filter Bar
- This topic has 16 replies, 2 voices, and was last updated 6 years, 5 months ago by Todd.
-
AuthorPosts
-
September 13, 2017 at 6:17 am #1348515ToddParticipant
Hi, I have had a relatively easy time customizing templates to get the data I want thanks to your great knowledgebase, forum and docs (styling of site will come soon!).
One area that I am not finding success is in getting custom taxonomies onto the search filter bar. I understand that you don’t provide that kind of support, but my question is have you come across code from anyone that has successfully achieved this, as I can’t find it on my own.
The best one I can find is Frederick’s work. But I’ve been unable to implement it. If this looks like the best solution to you as well, would you be able to provide some general direction towards its implementation?
Thank you!September 13, 2017 at 2:11 pm #1348881CliffMemberHi, Todd.
Please reference https://theeventscalendar.com/knowledgebase/creating-custom-filters-for-filter-bar/ and if that’s not helpful enough, please see /wp-content/plugins/the-events-calendar-filterbar/src/Tribe/Filters/Category.php for an example of how our custom taxonomy gets added.
Please let me know how this goes for you.
September 13, 2017 at 8:18 pm #1348978ToddParticipantThanks for your direction, I found my problem – I was saving new filter in the /wp-content/plugins/the-events-calendar-filterbar/src/Tribe/Filters/ folder but it needs to be saved in functions or as plugin. It does work perfectly in functions.php, but does not as a plug-in. Do you know why this might be?
September 14, 2017 at 9:15 am #1349227CliffMemberGlad you got that sorted out.
If it’s in a plugin, it should work just fine but make sure you go to /wp-admin/plugins.php and click to Activate it.
If the plugin is activated and it’s the exact same code as what works via your active theme’s functions.php, but it’s still not working, please send me the full plugin .zip so I can try it out.
September 21, 2017 at 10:56 pm #1353188ToddParticipantThanks Cliff, been trying to figure out on my own but can’t… I’ve attached the plugin, which is still not working at all as a plug-in for me (dumb error on my part?), and now only half-works in functions.php. The taxonomy filters (from venue) show up but when selected return no results. Thanks for taking a look.
September 22, 2017 at 8:46 pm #1353756CliffMemberTodd, I can look into this a bit further, but at first glance I see you already have the PRO add-on as well. Why not just use a PRO Additional Field for your Neighborhoods filtering? It will automatically appear in Filter Bar.
September 22, 2017 at 8:49 pm #1353757ToddParticipantThanks for the reply. I chose custom taxonomy because I need hierarchical terms. Is there a way to do that in filter bar? For example USA => FLORIDA => MIAMI, where user can search for just USA, Florida or Miami?
September 26, 2017 at 3:59 pm #1355249CliffMemberHi, Todd. Sorry for the delay getting back to you on this.
The reason it does not work as a plugin is because it extends a class that does not yet exist. You would need to only load the plugin’s code at a later point. Therefore, it’s easier to just keep in your functions.php file, which runs after all the active plugins are loaded.
As for your custom taxonomy, I wouldn’t be able to assist there because I can’t test any code I’d come up with to see if it works, since I don’t have that custom taxonomy on my site.
Did you know Filter Bar has built-in filtering by country, state/province, and city? Just make sure your events are assigned to venues that have location data! Also, go to wp-admin > Events > Settings > Filters and make sure you have the desired filters active.
Please let me know how this goes for you.
October 3, 2017 at 10:29 pm #1358703ToddParticipantThanks Cliff for the additional information, I’ll keep it in functions.php then (a bit cleaner to have in plugin, but no problem either way.)
Can you offer me some direction on executing the search? The custom taxonomy is showing in the filter bar (custom taxonomy=’neighborhood’) but when I click on an option I get no results. My url is “…?action=tribe_event_day&tribe-bar-date=2017-10-04&tribe_neighborhoodcustom%5B%5D=101”. I’ve used the code discussed in my initial post to implement the filter. I’ve tried many versions of the query (i.e. &neighborhood, &tribe_neighborhood, etc.). Do you know where I might check to get back on track?
October 4, 2017 at 8:29 pm #1359326CliffMembertribe_neighborhoodcustom is definitely the URL query arg, but you shouldn’t be guessing how to get to it. You should be using Filter Bar to generate the URL(s) for you, at least to get started.
Does Filter Bar display your custom filter and the expected choices?
If so, it should generate the appropriate URL for you, like …&tribe_neighborhoodcustom=101 and then display the expected events.
Is it that everything’s working except the results aren’t what are expected?
October 4, 2017 at 9:18 pm #1359340ToddParticipantThanks Cliff, yes that’s correct.. I’m getting what looks like the correct URL (it is similar to what other working URLs look like when I check different filters) but with this one I get zero results. The non-working URL is this:
/events/2017-10-05/?action=tribe_event_day&tribe-bar-date=2017-10-05&tribe_neighborhoodcustom%5B%5D=101October 4, 2017 at 9:18 pm #1359341ToddParticipantThis reply is private.
- This reply was modified 6 years, 6 months ago by Todd. Reason: adding pastebin
October 5, 2017 at 2:29 am #1359404CliffMemberThis reply is private.
October 8, 2017 at 2:04 pm #1360991October 9, 2017 at 3:40 pm #1361311CliffMemberThis reply is private.
-
AuthorPosts
- The topic ‘Adding Custom Taxonomy to Filter Bar’ is closed to new replies.