{"id":1048310,"date":"2015-12-30T21:44:53","date_gmt":"2015-12-31T05:44:53","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/"},"modified":"2016-01-02T16:40:49","modified_gmt":"2016-01-03T00:40:49","slug":"custom-query-with-tax_query-not-working","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/","title":{"rendered":"Custom query with tax_query not working"},"content":{"rendered":"<p>I am trying to query events by category, but when I add a tax_query to my query args, it stops working. I&#8217;ve verified that the categories have events in them. What might be the issue?<\/p>\n<pre><code>\/\/Generates the boxes in the main nav menu with\nfunction ac_flyoutBoxes($itemID) {\n\tif (!$itemID) {\n\t\t\treturn false;\n\t}\n\tif (!is_int($itemID)) {\n\t\t$itemID = intval($itemID);\n\t\t\/\/echo $itemID.&#039;&lt;br \/&gt;&#039;;\n\t}\n\t\/\/Query for events in this particular term\n\t$args = array(\n\t\t&#039;post_type&#039; =&gt; Tribe__Events__Main::POSTTYPE,\n\t\t&#039;tax_query&#039; =&gt; array(\n\t\t\t\tarray(\n\t\t\t\t\t&#039;taxonomy&#039; =&gt; TribeEvents::TAXONOMY,\n\t\t\t\t\t&#039;field&#039; =&gt; &#039;term_id&#039;,\n\t\t\t\t\t&#039;terms&#039; =&gt; array($itemID),\n\t\t\t\t ),\n\t\t\t  ),\n\t\t  &#039;meta_key&#039;=&gt;&#039;_EventStartDate&#039;,\n\t\t  &#039;orderby&#039;=&gt;&#039;meta_value&#039;,\n\t\t  &#039;order&#039;=&gt;&#039;DESC&#039;,\n\t\t  &#039;posts_per_page&#039; =&gt; 5,\n\t);\n\t$the_query = new WP_Query( $args );\n$output = &#039;&#039;;\n$output .= &#039;&lt;div class=&quot;flyoutBoxes&quot;&gt;&#039;;\n\tif ( $the_query-&gt;have_posts() ) {\n\t\t\n\t\twhile ( $the_query-&gt;have_posts() ) {\n\t\t\t$the_query-&gt;the_post(); \n\t\t\t$output .= &#039;&lt;div class=&quot;flyoutBox&quot;&gt;&#039;.get_the_title().&#039;&lt;\/div&gt;&#039;;\n\t\t}\n\n\t} else { \n\t\t$output .= &#039;&lt;div class=&quot;flyoutBox&quot;&gt;No events found!&lt;\/div&gt;&#039;;\n\t}\n\n$output .= &#039;&lt;\/div&gt;&#039;;\n\n\twp_reset_postdata();\n\t\n\treturn $output;\n}<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-1048310","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>Custom query with tax_query not working -<\/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\/custom-query-with-tax_query-not-working\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom query with tax_query not working -\" \/>\n<meta property=\"og:description\" content=\"I am trying to query events by category, but when I add a tax_query to my query args, it stops working. I&#8217;ve verified that the categories have events in them. What might be the issue? \/\/Generates the boxes in the main nav menu with function ac_flyoutBoxes($itemID) { if (!$itemID) { return false; } if (!is_int($itemID)) [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-01-03T00:40:49+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\/custom-query-with-tax_query-not-working\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/\",\"name\":\"Custom query with tax_query not working -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-12-31T05:44:53+00:00\",\"dateModified\":\"2016-01-03T00:40:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/#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\":\"Custom query with tax_query not working\"}]},{\"@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":"Custom query with tax_query not working -","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\/custom-query-with-tax_query-not-working\/","og_locale":"en_US","og_type":"article","og_title":"Custom query with tax_query not working -","og_description":"I am trying to query events by category, but when I add a tax_query to my query args, it stops working. I&#8217;ve verified that the categories have events in them. What might be the issue? \/\/Generates the boxes in the main nav menu with function ac_flyoutBoxes($itemID) { if (!$itemID) { return false; } if (!is_int($itemID)) [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/","article_modified_time":"2016-01-03T00:40:49+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\/custom-query-with-tax_query-not-working\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/","name":"Custom query with tax_query not working -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-12-31T05:44:53+00:00","dateModified":"2016-01-03T00:40:49+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-query-with-tax_query-not-working\/#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":"Custom query with tax_query not working"}]},{"@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\/1048310","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\/1048310\/revisions"}],"predecessor-version":[{"id":1049169,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1048310\/revisions\/1049169"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1048310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}