Home › Forums › Calendar Products › Filter Bar › Filter for Additional Field
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by Barry.
-
AuthorPosts
-
April 15, 2014 at 5:47 pm #133634crystalbridgesParticipant
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?
April 16, 2014 at 6:35 am #133866crystalbridgesParticipantAnd 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’?
April 16, 2014 at 9:52 am #134012crystalbridgesParticipantCan’t edit posts…
I meant to say in previous post:
Is there a way to query for ‘TribeEvents::MYCUSTOMTAXONOMY’ or ‘TribeEvents::MYADDITIONALFIELD’?April 17, 2014 at 9:03 am #135300BarryMemberJust 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.
April 21, 2014 at 12:57 pm #138761crystalbridgesParticipantI 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.
April 22, 2014 at 6:55 am #139414BarryMemberExcellent work – thanks for sharing!
-
AuthorPosts
- The topic ‘Filter for Additional Field’ is closed to new replies.