{"id":1329805,"date":"2017-08-02T17:00:53","date_gmt":"2017-08-03T00:00:53","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/"},"modified":"2017-08-02T17:00:53","modified_gmt":"2017-08-03T00:00:53","slug":"output-hierarchical-list-of-upcoming-event-categories","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/","title":{"rendered":"Output Hierarchical List of Upcoming Event Categories"},"content":{"rendered":"<p>Hi there,<\/p>\n<p>I\u2019m hoping someone can help me out with this. Basically what I am trying to do is create a hierarchical list of all upcoming event categories (which will be used as a menu).<\/p>\n<p>I am already able to output only upcoming event categories with the following code: <\/p>\n<pre><code>\t\t&lt;?php \n\t\t\/\/ Get all of the upcoming events\t\n\t\t$events = tribe_get_events( array(\n\t\t    &#039;eventDisplay&#039; =&gt; upcoming,\n\t\t    &#039;posts_per_page&#039; =&gt; -1,\n\t\t)); \n\t\n\t\t\/\/ Loop through the upcoming events with tribe events category taxonomy\n\t\tforeach ( $events as $event ) {\t\n\t\t\t\/\/Put each upcoming category in an array\n\t\t\t$cats[] = get_terms( array(\n\t\t\t\t&#039;taxonomy&#039; =&gt; tribe_events_cat) \n\t\t\t);\n\t\t} \n\t\n\t\t\/\/Grab unique categories and put those in an array\n\t\t$cat_results = array_unique($cats);\n$count = 0;\n\n\t\t\/\/ Loop through the unique array of categories\n\t\tforeach($cat_results as $cat_result){\n\t\t\t\/\/ Loop through the terms\n\t\t\tforeach($cat_result as $the_result){\n\t\t\t\t\/\/ Output the name for each unique category\n\t\t\t\techo $the_result-&gt;name . &#039;&lt;br\/&gt;&#039;;\n\t\t\t}\n\t\t\t\n\t\t} \t\n\t\t?&gt;<\/code><\/pre>\n<p>However this returns a list that does not show any type of category hierarchy<br \/>\ne.g. This is what I get:<br \/>\n<em>Adults<br \/>\nBoys<br \/>\nCamps<br \/>\nChristmas<br \/>\nGirls<br \/>\nHigh School<br \/>\nKelowna, British Columbia<br \/>\nMens<br \/>\nPond Hockey<br \/>\nQuebec City, Quebec<br \/>\nTournaments<br \/>\nWomens<\/em><\/p>\n<p>However I would like to output a hierarchical list like so:<br \/>\n<em>Camps<br \/>\n\u2014Adults<br \/>\n\u2014Christmas<br \/>\nTournaments<br \/>\n\u2014Boys<br \/>\n\u2014\u2014Quebec City, Quebec<br \/>\n\u2014Girls<br \/>\n\u2014High School<br \/>\n\u2014\u2014Kelowna, British Columbia<br \/>\n\u2014Mens<br \/>\n\u2014Pond Hockey<br \/>\n\u2014Womens<\/em><\/p>\n<p>I believe that I am already headed in the right direction, if you have a look at the following code, I am able to break the list up by the parent categories. However the sub-categories listed below the parent are not displaying ONLY subcategories with upcoming events &#8211; they are displaying ALL subcategories.<\/p>\n<pre><code>\t\t&lt;?php  \n\n\t\t$parentCategories = get_terms(array(\n\t\t\t&#039;taxonomy&#039; =&gt; tribe_events_cat,\n\t\t\t&#039;parent&#039; =&gt; 0, \n\t\t\t&#039;orderby&#039; =&gt; &#039;slug&#039;, \n\t\t\t&#039;hide_empty&#039; =&gt; false \n\t\t) );\n\t\tforeach($parentCategories as $pcat){\n\t\t\techo &#039;&lt;strong&gt;&#039; . $pcat-&gt;name . &#039;&lt;\/strong&gt;&lt;br\/&gt;&#039;;\n\n\t\t\t\/\/ GET ALL EVENTS THAT ARE UNDER THE PARENT CATEGORY\n\t\t\t$leEvents = tribe_get_events( array(\n\t\t\t    &#039;eventDisplay&#039; =&gt; upcoming,\n\t\t\t    &#039;posts_per_page&#039; =&gt; -1,\n\t\t\t    &#039;tax_query&#039; =&gt; array(\n\t\t\t\t\t    array(\n\t\t\t\t\t\t    &#039;taxonomy&#039; =&gt; &#039;tribe_events_cat&#039;,\n\t\t\t\t\t\t    &#039;field&#039; =&gt; &#039;slug&#039;,\n\t\t\t\t\t\t    &#039;terms&#039; =&gt; $pcat-&gt;slug\n\t\t\t\t\t    ))\t\t\t    \n\t\t\t)); \n\t\t\t\n\t\t\tforeach($leEvents as $leEvent){\n\t\t\t\n\t\t\t\t$leagueCategories = get_terms( array( \n\t\t\t\t\t&#039;taxonomy&#039; =&gt; tribe_events_cat,\t\t\t\t\n\t\t\t\t\t&#039;parent&#039; =&gt; $pcat-&gt;term_id, \n\t\t\t\t\t&#039;orderby&#039; =&gt; &#039;slug&#039;, \n\t\t\t\t\t&#039;hide_empty&#039; =&gt; false\n\t\t\t\t) );\t\n\t\t\t}\n\t\t\t\t\t\n\t\t\tforeach($leagueCategories as $lecat){\n\t\t\t\techo $lecat-&gt;name . &#039;&lt;br\/&gt;&#039;;\n\n\t\t\t\t\/\/ GET ALL EVENTS THAT ARE UNDER THE PARENT CATEGORY\n\t\t\t\t$locEvents = tribe_get_events( array(\n\t\t\t\t    &#039;eventDisplay&#039; =&gt; upcoming,\n\t\t\t\t    &#039;posts_per_page&#039; =&gt; -1,\n\t\t\t\t    &#039;tax_query&#039; =&gt; array(\n\t\t\t\t\t\t    array(\n\t\t\t\t\t\t\t    &#039;taxonomy&#039; =&gt; &#039;tribe_events_cat&#039;,\n\t\t\t\t\t\t\t    &#039;field&#039; =&gt; &#039;slug&#039;,\n\t\t\t\t\t\t\t    &#039;terms&#039; =&gt; $lecat-&gt;slug\n\t\t\t\t\t\t    ))\t\t\t    \n\t\t\t\t)); \n\n\t\t\t\tforeach($locEvents as $locEvent){\n\t\t\t\t\t$locationCategories = get_terms( array( \n\t\t\t\t\t\t&#039;taxonomy&#039; =&gt; tribe_events_cat,\t\t\t\t\n\t\t\t\t\t\t&#039;parent&#039; =&gt; $lecat-&gt;term_id, \n\t\t\t\t\t\t&#039;orderby&#039; =&gt; &#039;slug&#039;, \n\t\t\t\t\t\t&#039;hide_empty&#039; =&gt; false \n\t\t\t\t\t) );\n\t\t\t\t}\t\n\t\t\t\t\n\t\t\t\tforeach($locationCategories as $locat){\n\t\t\t\t\techo $locat-&gt;name . &#039;&lt;br\/&gt;&#039;;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}<\/code><\/pre>\n<p>I am aware that you are limited in the amount of customization you can help out with, that being said if you have any input at all as to why this may not be working as expected &#8211; that would be very much appreciated.<br \/>\n\u2028<br \/>\nThank you.<\/p>\n","protected":false},"template":"","class_list":["post-1329805","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>Output Hierarchical List of Upcoming Event Categories -<\/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\/output-hierarchical-list-of-upcoming-event-categories\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Output Hierarchical List of Upcoming Event Categories -\" \/>\n<meta property=\"og:description\" content=\"Hi there, I\u2019m hoping someone can help me out with this. Basically what I am trying to do is create a hierarchical list of all upcoming event categories (which will be used as a menu). I am already able to output only upcoming event categories with the following code: &lt;?php \/\/ Get all of the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/\",\"name\":\"Output Hierarchical List of Upcoming Event Categories -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2017-08-03T00:00:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/#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\":\"Output Hierarchical List of Upcoming Event Categories\"}]},{\"@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":"Output Hierarchical List of Upcoming Event Categories -","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\/output-hierarchical-list-of-upcoming-event-categories\/","og_locale":"en_US","og_type":"article","og_title":"Output Hierarchical List of Upcoming Event Categories -","og_description":"Hi there, I\u2019m hoping someone can help me out with this. Basically what I am trying to do is create a hierarchical list of all upcoming event categories (which will be used as a menu). I am already able to output only upcoming event categories with the following code: &lt;?php \/\/ Get all of the [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/","name":"Output Hierarchical List of Upcoming Event Categories -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2017-08-03T00:00:53+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/output-hierarchical-list-of-upcoming-event-categories\/#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":"Output Hierarchical List of Upcoming Event Categories"}]},{"@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\/1329805","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\/1329805\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1329805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}