Filter for Additional Field

Home Forums Calendar Products Filter Bar Filter for Additional Field

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #133634
    crystalbridges
    Participant

    This question has been asked a few times, but I haven’t found a solution in the forum, in a tutorial, or through my own efforts.

    I am trying to create a filter on the filter bar for an additional field. I have tried the tutorial here: https://theeventscalendar.com/understanding-the-tribeeventsbar/ as well as read multiple questions on your support forums and documents. I am trying to create a set of tags to add to events that doesn’t include the WordPress default ‘tags’.

    I created a new filter page based on TribeEventsFilter_Category.php called TribeEventsFilter_CustomTag.php. I added a line to tribe-filter-view.class.php to include this file (I will eventually add a filter instead of hard coding this):
    new TribeEventsFilter_CustomTag( __( ‘Custom Tags’, ‘tribe-events-filter-view’ ), ‘customtags’);

    What I can’t figure out is how to query for a ‘term’ for an additional field. In my case the additional field is called Custom Tags. The line in TribeEventsFilter_CustomTag.php that needs to be edited is:

    $custom_tags_term = get_terms( TribeEvents::TAXONOMY, array( ‘orderby’ => ‘name’, ‘order’ => ‘DESC’ ) );

    I have tried:
    $custom_tags_term = get_terms( ‘custom_tags’, array( ‘orderby’ => ‘name’, ‘order’ => ‘DESC’ ) );

    I have also tried ‘customtags’, ‘custom_tag’, and ‘customtag’ for the term query. I searched the database for any instance of the above strings and only found custom_tags in wp_term_taxonomy. None of these work, leaving the filter drop down empty. How should I edit this query to pull in the additional field values for the filterbar?

    #133866
    crystalbridges
    Participant

    And from further research on “TribeEvents::TAXONOMY” it appears to be linked to event categories. Is this the only way to query for ‘TribeEvents::MYCUSTOMTAXONOMY’ or ‘TribeEvents::MYADDITIONALFIELD’?

    #134012
    crystalbridges
    Participant

    Can’t edit posts…

    I meant to say in previous post:
    Is there a way to query for ‘TribeEvents::MYCUSTOMTAXONOMY’ or ‘TribeEvents::MYADDITIONALFIELD’?

    #135300
    Barry
    Member

    Just to clarify, the tutorial you referenced relates to the Tribe Events Bar (which does itself contain filters) rather than the Filter Bar in the sense of the specific Filter Bar plugin. Right now I don’t believe we’ve got any tutorial resources specifically covering what you seem to want to do, but we’d definitely look at producing one if you want to post a request for this 🙂

    It is unfortunately a bit beyond what we can help directly with here on the forum.

    #138761
    crystalbridges
    Participant

    I was able to get a custom taxonomy (custom tags, to distinguish from built in WP ‘tags’), and place it on the filterbar and filter events correctly.

    First I created the taxonomy. I am using a custom plugin, but you can do the same thing in functions.php. Pastebin: http://pastebin.com/dpreiNMs

    Then I made a copy of ‘/wp-content/plugins/the-events-calendar-filterbar/lib/filtersTribeEventsFilter_Category.php’ and called it ‘TribeEventsFilter_CustomTag.php’. I changed all instances of ‘event_categories’ to ‘custom_tags’. Then change the queries to pull in the correct taxonomy term list. Basically you replace ‘TribeEvents::TAXONOMY’ with ‘custom_tags’. So now it should pull your list in. Pastebin: http://pastebin.com/BPtMTnbs.

    Then go to /wp-content/plugins/the-events-calendar-filterbar/lib/tribe-filter-view.class.php, and around line 282, you need to add a line to point to your new file. Like this:
    new TribeEventsFilter_CustomTag( __( ‘Custom Tags’, ‘tribe-events-filter-view’ ), ‘customtags’);
    I will eventually remove this line add it in a hook in my custom plugin.

    Remember if you haven’t created any custom tags, and/or do not have any events associated with the custom tags, the query won’t pull anything and it won’t appear to work.

    #139414
    Barry
    Member

    Excellent work – thanks for sharing!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Filter for Additional Field’ is closed to new replies.