{"id":743472,"date":"2014-09-14T08:15:07","date_gmt":"2014-09-14T15:15:07","guid":{"rendered":"http:\/\/tri.be\/support\/forums\/topic\/adding-a-custom-filter\/"},"modified":"2014-09-15T11:32:07","modified_gmt":"2014-09-15T18:32:07","slug":"adding-a-custom-filter","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/","title":{"rendered":"Adding a custom filter"},"content":{"rendered":"<p>Hi,<\/p>\n<p>Like other people in this forum, I am trying to figure out, how to add custom filters based on custom taxonomies. I found this other threads:<\/p>\n<p>https:\/\/tri.be\/support\/forums\/topic\/when-will-you-release-the-ability-to-configure-filter-bar-with-custom-categories\/<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"Hu5x1dqjry\"><p><a href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-custom-filter-to-filter-bar\/\">Adding Custom Filter to Filter Bar<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;Adding Custom Filter to Filter Bar&#8221; &#8212; \" src=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-custom-filter-to-filter-bar\/embed\/#?secret=FSZ5DtR4oF#?secret=Hu5x1dqjry\" data-secret=\"Hu5x1dqjry\" width=\"580\" height=\"327\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"fDqhKNTDzi\"><p><a href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-can-i-change-the-venue-filter-to-show-the-city-or-state-field\/\">How can I change the Venue Filter to show the City or State field?<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"&#8220;How can I change the Venue Filter to show the City or State field?&#8221; &#8212; \" src=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-can-i-change-the-venue-filter-to-show-the-city-or-state-field\/embed\/#?secret=rIYfoxsOGz#?secret=fDqhKNTDzi\" data-secret=\"fDqhKNTDzi\" width=\"580\" height=\"327\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>But in none of them there is the right solution or an example of doing it. <\/p>\n<p>I created a new filter class (based on the TribeEventsFilter_Category class) named TribeEventsFilter_City. Since here is everything ok. But, how can I attach it to the filters array? As Brook answers <a href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/how-can-i-change-the-venue-filter-to-show-the-city-or-state-field\/\">here<\/a>, &lt;i&gt;&#8221;Once you have created your TEC filter you would need to attach it. How I would do it is by adding my TEC filter to the tribe_events_all_filters_array. That is WP filter that you can hook into with add_filter. Simply add your TEC filter to the end of that array and return.&#8221;&lt;\/i&gt;<\/p>\n<p>As Barry points in <a href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-custom-filter-to-filter-bar\/\">this thread<\/a>, this must be like this:<\/p>\n<pre>\nadd_filter( 'tribe_events_all_filters_array', 'custom_add_filter_callback' );\nfunction custom_add_filter_callback( $filters ) {\n\t$filters['unique_slug'] = array(\n\t\t'name' =&gt; 'your_filter_name',\n\t\t'type' =&gt; '''',\n\t\t'admin_form' =&gt; '',\n\t);\n\treturn $filters;\n}\n<\/pre>\n<p>But, what must be this &#8220;unique_slug&#8221;? And &#8220;your_filter_name&#8221;? &#8220;type&#8221;? How can be this item &#8220;related&#8221; to my new class? Or where must be the new instance of the class created? I mean something like this (like in the initialize_filters() function in tribe-filter-view.class.php).<\/p>\n<p>Could you post an example with a class and a tribe_events_all_filters_array callback?<\/p>\n<p>Thanks for your support!<\/p>\n","protected":false},"template":"","class_list":["post-743472","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Adding a custom filter  -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adding a custom filter  -\" \/>\n<meta property=\"og:description\" content=\"Hi, Like other people in this forum, I am trying to figure out, how to add custom filters based on custom taxonomies. I found this other threads: https:\/\/tri.be\/support\/forums\/topic\/when-will-you-release-the-ability-to-configure-filter-bar-with-custom-categories\/ Adding Custom Filter to Filter Bar How can I change the Venue Filter to show the City or State field? But in none of them there is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-09-15T18:32:07+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/\",\"name\":\"Adding a custom filter -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-09-14T15:15:07+00:00\",\"dateModified\":\"2014-09-15T18:32:07+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Filter Bar\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/filter-bar\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Adding a custom filter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Adding a custom filter  -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/","og_locale":"en_US","og_type":"article","og_title":"Adding a custom filter  -","og_description":"Hi, Like other people in this forum, I am trying to figure out, how to add custom filters based on custom taxonomies. I found this other threads: https:\/\/tri.be\/support\/forums\/topic\/when-will-you-release-the-ability-to-configure-filter-bar-with-custom-categories\/ Adding Custom Filter to Filter Bar How can I change the Venue Filter to show the City or State field? But in none of them there is [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/","article_modified_time":"2014-09-15T18:32:07+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/","name":"Adding a custom filter -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-09-14T15:15:07+00:00","dateModified":"2014-09-15T18:32:07+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-filter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Filter Bar","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/filter-bar\/"},{"@type":"ListItem","position":5,"name":"Adding a custom filter"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/743472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/743472\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=743472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}