Filter by Custom Taxonomy
-
Hi!, I’ve been trying to find an answer about how to do this, i need be able to use the filter bar, to filter by events categories and a custom taxonomy named “event type” where we can find types as “twitter-chat”, “google hangouts” etc.
I followed up this recommendation http://tri.be/support/forums/topic/filter-for-additional-field/
Everything looks fine, but when i started to testing, i can’t get the filter for both things.
It filter by Event Category OR Custom Taxonomy (“Event Type”), instead both.
I mean, if i have an event with category a, but event type twitter-chat, and another with category b, but event type: google hangout.It returns the result only for the event type, and not filtering by the category.
Here the custom snippet that i created:
In filterbar/lib/filters/TribeEventsFilter_Category.php file:
protected function setup_query_args() {
$this->queryArgs[‘tax_query’] = array( ‘relation’ => ‘AND’, array(
‘taxonomy’ => TribeEvents::TAXONOMY,
‘field’ => ‘id’,
‘terms’ => $this->currentValue,
‘include_children’ => false,
) );}
and In filterbar/lib/filters/TribeEventsFilter_EventType.php file:
protected function setup_query_args() {
$this->queryArgs[‘tax_query’] = array( ‘relation’ => ‘AND’, array(
‘taxonomy’ => ‘event_type’,
‘field’ => ‘id’,
‘terms’ => $this->currentValue,
‘include_children’ => false,
) );
}As i understand, this, get the args for tax queries in an array where the relation is ‘AND’ with the other taxonomy.
Then, the query should filter where Category = B AND Event Type = ‘twitter-chat’
And returns only the events that matches with that criteria, but… it is doing the query like:‘Event type’ = twitter-chat, without consider the category selected.
I understand, this can’t be a common support request, but, i have a deadline for this week to get this filter working, and i can’t wait for a new release, hope you can help me 🙁
Thankyou
The topic ‘Filter by Custom Taxonomy’ is closed to new replies.