{"id":1145573,"date":"2016-07-29T08:34:49","date_gmt":"2016-07-29T15:34:49","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/"},"modified":"2016-08-03T09:40:26","modified_gmt":"2016-08-03T16:40:26","slug":"adding-a-custom-taxonomy-or-event-meta-filter","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/","title":{"rendered":"Adding a custom taxonomy or event meta filter"},"content":{"rendered":"<p>We use a quite complicated taxonomy system which we are using with our events, and I have also added a number of custom meta items to them which I have added filters for using the action hook &#8216;pre_get_posts&#8217;<\/p>\n<p>When loading the events week or month view from a direct link or refreshing the filters apply, however if I scroll through months from the navigation links at the bottom of the month view they do not (until I refresh).<\/p>\n<p>Here&#8217;s a snippet of the code I&#8217;m using for a simple meta filter:<\/p>\n<pre><code>add_action( 'pre_get_posts', 'get_tribe_events_posts_exclude_cancelled' );\r\nfunction get_tribe_events_posts_exclude_cancelled( $query ) {\r\n\tif ( is_post_type_archive( 'tribe_events' ) &amp;&amp;  !is_admin() ) {\r\n\t\t$metaquery[] = array(\r\n\t\t\tarray(\r\n\t\t\t\t'key' \t   =&gt; get_event_custom_field_key('Event Cancelled'),\r\n\t\t\t\t'value'    =&gt; 'Yes',\r\n\t\t\t\t'compare'  =&gt; '!=',\r\n\t\t\t),\r\n\t\t);\r\n\t\t$query-&gt;set('meta_query', $metaquery);\r\n\t}\r\n}<\/code><\/pre>\n<p>Note get_event_custom_field_key is a custom function I created to find the postmeta ket from the name used when creating it, (is there a proper function for this?)<\/p>\n<p>Also, is it possible when searching or browsing through the function arachive to be able to hide depricated functions? As a new user I don&#8217;t want to use them and there are a lot of them.<\/p>\n","protected":false},"template":"","class_list":["post-1145573","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 taxonomy or event meta 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-taxonomy-or-event-meta-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 taxonomy or event meta filter -\" \/>\n<meta property=\"og:description\" content=\"We use a quite complicated taxonomy system which we are using with our events, and I have also added a number of custom meta items to them which I have added filters for using the action hook &#8216;pre_get_posts&#8217; When loading the events week or month view from a direct link or refreshing the filters apply, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-08-03T16:40:26+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-taxonomy-or-event-meta-filter\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/\",\"name\":\"Adding a custom taxonomy or event meta filter -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-07-29T15:34:49+00:00\",\"dateModified\":\"2016-08-03T16:40:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-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\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Adding a custom taxonomy or event meta 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 taxonomy or event meta 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-taxonomy-or-event-meta-filter\/","og_locale":"en_US","og_type":"article","og_title":"Adding a custom taxonomy or event meta filter -","og_description":"We use a quite complicated taxonomy system which we are using with our events, and I have also added a number of custom meta items to them which I have added filters for using the action hook &#8216;pre_get_posts&#8217; When loading the events week or month view from a direct link or refreshing the filters apply, [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/","article_modified_time":"2016-08-03T16:40:26+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-taxonomy-or-event-meta-filter\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/","name":"Adding a custom taxonomy or event meta filter -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-07-29T15:34:49+00:00","dateModified":"2016-08-03T16:40:26+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-filter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adding-a-custom-taxonomy-or-event-meta-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":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Adding a custom taxonomy or event meta 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\/1145573","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":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1145573\/revisions"}],"predecessor-version":[{"id":1147169,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1145573\/revisions\/1147169"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1145573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}