Adding Custom Filter to Filter Bar

Home Forums Calendar Products Filter Bar Adding Custom Filter to Filter Bar

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1139301
    Jean-Philippe
    Participant

    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

    #1139514
    Brook
    Participant

    Howdy 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

    #1147669
    Support Droid
    Keymaster

    This 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.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Adding Custom Filter to Filter Bar’ is closed to new replies.