Home › Forums › Calendar Products › Filter Bar › Adding Custom Filter to Filter Bar
- This topic has 3 replies, 4 voices, and was last updated 7 years, 9 months ago by Jean-Philippe.
-
AuthorPosts
-
July 13, 2016 at 12:15 pm #1139301Jean-PhilippeParticipant
since i dont want to invade someone else post im refining on a question with an answer i saw in the forums earlier
I wish to add a custom filter linked to a custom taxonomy that is in turn linked to my event.
I saw this code:add_filter( 'tribe_events_all_filters_array', 'custom_add_filter_callback' ); function custom_add_filter_callback( $filters ) { $filters['unique_slug'] = array( 'name' => 'your_filter_name', 'type' => '', 'admin_form' => '', ); return $filters; }
Its a good start but i would really like to know how to add the taxonomy data and make it available in the filter-bar.
thanks
July 13, 2016 at 11:40 pm #1139514BrookParticipantHowdy Jean,
I would love to help you with this.
I actually an example of adding a second taxonomy filter available:
https://gist.github.com/elimn/99bf67696bb3e1be85d9c4b0300314c5
My filter is not actually for a separate taxonomy, but rather it is the regular category filter styled a bit differently. But it should still prove pretty helpful in showing how best to add filters.
I started by extending <span class=”pl-e”>Tribe__Events__Filterbar__Filters__Category which is located in the-events-calendar-filterbar/src/Tribe/Filters/Category.php and I would recommend you do the same. In you case you would likely want to override the pre_get_posts() method in that function with one of your own. If I understand you right all you want to do is the change the taxonomy itself, so if you copy/paste the current method into you new class that extends the old (like my example) then just change the taxonomy in there you should be all set!</span>
Does that all make sense? Will that work for you? Please let me know.
Cheers!
– Brook
August 4, 2016 at 9:35 am #1147669Support DroidKeymasterThis 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 ‘Adding Custom Filter to Filter Bar’ is closed to new replies.