{"id":1301621,"date":"2017-06-22T04:46:33","date_gmt":"2017-06-22T11:46:33","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/"},"modified":"2017-06-22T04:46:33","modified_gmt":"2017-06-22T11:46:33","slug":"overriding-eventdisplay-in-custom-filter","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/","title":{"rendered":"Overriding eventDisplay in custom filter"},"content":{"rendered":"<p>Hey, I&#8217;m trying to make a filter to choose between upcoming, past and all events in the filter bar. I have made a few extra filters, filtering by year and month, and custom taxonomy, all of which are working as expected (with some exceptions due to ordering), but I can&#8217;t get this filter to work.<\/p>\n<p>Essentially, I&#8217;m trying to use the list view plus the filters to display a list of events. Default is to show upcoming events, so the eventDisplay-variable should be left empty\/default\/list. There are also two more options, custom and past, which I use the following function to inject into the query:<\/p>\n<pre><code>\tprotected function pre_get_posts( WP_Query $query ) {\n\t\tglobal $wpdb;\n\n\t\t$values = (array) $this-&gt;currentValue;\n\t\t$when = $values[0];\n\n\t\t$query-&gt;set(&#039;tribe_event_display&#039;, $when);\n\t\t$query-&gt;set(&#039;eventDisplay&#039;, $when);\n\t\tif ($when == &quot;past&quot;){\n\t\t\t$query-&gt;set(&#039;order&#039;, &#039;DESC&#039;);\n\t\t\t$query-&gt;set(&#039;orderby&#039;, &quot;{$wpdb-&gt;postmeta}.meta_value&quot;);\n\t\t}\n\t}<\/code><\/pre>\n<p>As you can see, I&#8217;ve tried with both tribe_event_display and eventDisplay, but neither work as expected \u2013 the output of the list is not affected at all, no matter which option is chosen.<\/p>\n<p>Can you lend a helping hand here?<\/p>\n","protected":false},"template":"","class_list":["post-1301621","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>Overriding eventDisplay in 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\/overriding-eventdisplay-in-custom-filter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Overriding eventDisplay in custom filter -\" \/>\n<meta property=\"og:description\" content=\"Hey, I&#8217;m trying to make a filter to choose between upcoming, past and all events in the filter bar. I have made a few extra filters, filtering by year and month, and custom taxonomy, all of which are working as expected (with some exceptions due to ordering), but I can&#8217;t get this filter to work. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/\" \/>\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\/overriding-eventdisplay-in-custom-filter\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/\",\"name\":\"Overriding eventDisplay in custom filter -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-06-22T11:46:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-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\":\"Overriding eventDisplay in 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":"Overriding eventDisplay in 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\/overriding-eventdisplay-in-custom-filter\/","og_locale":"en_US","og_type":"article","og_title":"Overriding eventDisplay in custom filter -","og_description":"Hey, I&#8217;m trying to make a filter to choose between upcoming, past and all events in the filter bar. I have made a few extra filters, filtering by year and month, and custom taxonomy, all of which are working as expected (with some exceptions due to ordering), but I can&#8217;t get this filter to work. [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/","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\/overriding-eventdisplay-in-custom-filter\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/","name":"Overriding eventDisplay in custom filter -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-06-22T11:46:33+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-custom-filter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/overriding-eventdisplay-in-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":"Overriding eventDisplay in 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\/1301621","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\/1301621\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1301621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}