{"id":998697,"date":"2015-08-25T05:03:39","date_gmt":"2015-08-25T12:03:39","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/"},"modified":"2015-08-27T15:09:02","modified_gmt":"2015-08-27T22:09:02","slug":"ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/","title":{"rendered":"AJAX requests not respecting pre_get_posts overrides to show recurrence setting"},"content":{"rendered":"<p>Hi there,<\/p>\n<p>Just wanted to follow up on this &#8211; https:\/\/theeventscalendar.com\/support\/forums\/topic\/debugging-ajax\/ &#8211; which actually WASN&#8217;T solved by changing the &#8216;Recurring event instances&#8217; setting in admin.<\/p>\n<p>Unchecking that setting merely shifted the problem. Now, when there&#8217;s a date search, recurrences were being shown as desired. However, when a keyword search was done, recurrences were being shown &#8211; whereas we want recurrences to be hidden in that case. Again, this was just AJAX requests &#8211; after an AJAX call, if the page was manually refreshed, the query vars returned everything as desired.<\/p>\n<p>So the issue here is that on AJAX requests, overriding &#8216;tribeHideRecurrence&#8217; using pre_get_posts doesn&#8217;t appear to work.<\/p>\n<p>The solution I&#8217;ve found is simple I guess &#8211; override the option using the filter for getting an option value:<\/p>\n<pre><code>add_filter( &#039;tribe_get_option&#039;, &#039;yh_tribe_get_recurrence_option&#039;, 99999, 3 );\nfunction yh_tribe_get_recurrence_option( $value, $option_name, $default ) {\n\n\tif ( $option_name == &#039;hideSubsequentRecurrencesDefault&#039; ) {\n\t\t$value = ! YH_EVENTS_SHOWING_RECURRENCES;\n\t}\n\n\treturn $value;\n}<\/code><\/pre>\n<p>Seems to work so far.<\/p>\n<p>So as far as I can tell this is a genuine bug, but I guess even when you fix it, the above hack will carry on working OK.<\/p>\n","protected":false},"template":"","class_list":["post-998697","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>AJAX requests not respecting pre_get_posts overrides to show recurrence setting -<\/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\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AJAX requests not respecting pre_get_posts overrides to show recurrence setting -\" \/>\n<meta property=\"og:description\" content=\"Hi there, Just wanted to follow up on this &#8211; https:\/\/theeventscalendar.com\/support\/forums\/topic\/debugging-ajax\/ &#8211; which actually WASN&#8217;T solved by changing the &#8216;Recurring event instances&#8217; setting in admin. Unchecking that setting merely shifted the problem. Now, when there&#8217;s a date search, recurrences were being shown as desired. However, when a keyword search was done, recurrences were being shown [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-08-27T22:09:02+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\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/\",\"name\":\"AJAX requests not respecting pre_get_posts overrides to show recurrence setting -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-08-25T12:03:39+00:00\",\"dateModified\":\"2015-08-27T22:09:02+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/#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\":\"AJAX requests not respecting pre_get_posts overrides to show recurrence setting\"}]},{\"@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":"AJAX requests not respecting pre_get_posts overrides to show recurrence setting -","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\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/","og_locale":"en_US","og_type":"article","og_title":"AJAX requests not respecting pre_get_posts overrides to show recurrence setting -","og_description":"Hi there, Just wanted to follow up on this &#8211; https:\/\/theeventscalendar.com\/support\/forums\/topic\/debugging-ajax\/ &#8211; which actually WASN&#8217;T solved by changing the &#8216;Recurring event instances&#8217; setting in admin. Unchecking that setting merely shifted the problem. Now, when there&#8217;s a date search, recurrences were being shown as desired. However, when a keyword search was done, recurrences were being shown [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/","article_modified_time":"2015-08-27T22:09:02+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\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/","name":"AJAX requests not respecting pre_get_posts overrides to show recurrence setting -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-08-25T12:03:39+00:00","dateModified":"2015-08-27T22:09:02+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/ajax-requests-not-respecting-pre_get_posts-overrides-to-show-recurrence-setting\/#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":"AJAX requests not respecting pre_get_posts overrides to show recurrence setting"}]},{"@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\/998697","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":2,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/998697\/revisions"}],"predecessor-version":[{"id":998836,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/998697\/revisions\/998836"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=998697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}