{"id":1228167,"date":"2017-02-02T08:01:47","date_gmt":"2017-02-02T16:01:47","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/"},"modified":"2017-02-02T08:01:47","modified_gmt":"2017-02-02T16:01:47","slug":"adjust-ajax-search-to-exclude-event-taxonomy","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/","title":{"rendered":"Adjust AJAX search to exclude event taxonomy"},"content":{"rendered":"<p>Dear Support-Team,<\/p>\n<p>I have been trying to exclude one event taxonomy from the frontend of my website. This has worked out quite well so far, until I tried to filter the AJAX search output.<\/p>\n<p>My Code so far is as follows:<br \/>\n<code>\/* Exclude non-booked events from frontend calendar *\/<br \/>\nfunction tribe_exclude_events_category( $wp_query ) {<br \/>\n\t$exclude_cats = array('easytruck-offen');<br \/>\n\tif ( is_admin() ) return $wp_query;<br \/>\n\tif (is_array($wp_query-&gt;tax_query))<br \/>\n\t\t$tax_query = $wp_query-&gt;tax_query;<br \/>\n\telse<br \/>\n\t\t$tax_query = array();<br \/>\n\t\t$tax_query[] = array(<br \/>\n\t\t\t'taxonomy'  =&gt; 'tribe_events_cat',<br \/>\n\t\t\t'field'     =&gt; 'slug',<br \/>\n\t\t\t'terms'     =&gt; $exclude_cats,<br \/>\n\t\t\t'operator'  =&gt; 'NOT IN'<br \/>\n\t\t);<br \/>\n\tif (tribe_is_event_query()) {<br \/>\n\t\t$wp_query-&gt;set('tax_query', $tax_query);<br \/>\n\t}<br \/>\n\treturn $wp_query;<br \/>\n}<br \/>\nadd_action( 'pre_get_posts', 'tribe_exclude_events_category', 100, 1 );<\/code><\/p>\n<p>This works well with all Calendar views and all WordPress search pages, however, the installed theme utilizes an AJAX search box in the header, which still displays posts from the unwanted taxonomy.<\/p>\n<p>The AJAX search file defines the variable <code>$td_query<\/code> as follows:<br \/>\n<code>$td_query = &amp;td_data_source::get_wp_query($ajax_parameters['td_atts'], $ajax_parameters['td_current_page']);<\/code><\/p>\n<p><code>get_wp_query()<\/code> looks like this:<br \/>\n<code>static function &amp;get_wp_query ($atts = '', $paged = '') {<br \/>\n        $args = self::shortcode_to_args($atts, $paged);<\/p>\n<p>        $td_query = new WP_Query($args);<br \/>\n        return $td_query;<br \/>\n    }<\/code><\/p>\n<p>My question: Is it possible to alter the function tribe_exclude_events_category() to also address the $td_query? Would you need additional information for this?<\/p>\n<p>Thank you in advance!<br \/>\nHave a great day!<\/p>\n","protected":false},"template":"","class_list":["post-1228167","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>Adjust AJAX search to exclude event taxonomy -<\/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\/adjust-ajax-search-to-exclude-event-taxonomy\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Adjust AJAX search to exclude event taxonomy -\" \/>\n<meta property=\"og:description\" content=\"Dear Support-Team, I have been trying to exclude one event taxonomy from the frontend of my website. This has worked out quite well so far, until I tried to filter the AJAX search output. My Code so far is as follows: \/* Exclude non-booked events from frontend calendar *\/ function tribe_exclude_events_category( $wp_query ) { $exclude_cats [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/\" \/>\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\/adjust-ajax-search-to-exclude-event-taxonomy\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/\",\"name\":\"Adjust AJAX search to exclude event taxonomy -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-02-02T16:01:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/#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\":\"Adjust AJAX search to exclude event taxonomy\"}]},{\"@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":"Adjust AJAX search to exclude event taxonomy -","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\/adjust-ajax-search-to-exclude-event-taxonomy\/","og_locale":"en_US","og_type":"article","og_title":"Adjust AJAX search to exclude event taxonomy -","og_description":"Dear Support-Team, I have been trying to exclude one event taxonomy from the frontend of my website. This has worked out quite well so far, until I tried to filter the AJAX search output. My Code so far is as follows: \/* Exclude non-booked events from frontend calendar *\/ function tribe_exclude_events_category( $wp_query ) { $exclude_cats [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/","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\/adjust-ajax-search-to-exclude-event-taxonomy\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/","name":"Adjust AJAX search to exclude event taxonomy -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-02-02T16:01:47+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/adjust-ajax-search-to-exclude-event-taxonomy\/#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":"Adjust AJAX search to exclude event taxonomy"}]},{"@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\/1228167","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\/1228167\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1228167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}