{"id":974807,"date":"2015-07-02T12:04:50","date_gmt":"2015-07-02T19:04:50","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/"},"modified":"2015-07-21T07:05:03","modified_gmt":"2015-07-21T14:05:03","slug":"custom-loop-that-displays-month-headers-and-conditionally-displays-categories","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/","title":{"rendered":"Custom Loop that Displays Month Headers and Conditionally Displays Categories"},"content":{"rendered":"<p>I hope it is ok for me to combine two questions in one because they both refer to coding a custom event loop. Thank you for you help ahead of time.<br \/>\n1) How would I write code that puts Month headers in the appropriate location so that a list of events can be separated by their start date month?<br \/>\nJune<br \/>\nEvent #1<br \/>\nEvent #2<br \/>\nJuly<br \/>\nEvent #3<br \/>\nEvent #4<br \/>\netc&#8230;<br \/>\n2) How would I write a conditional statement that only displays the category if the category slug is &#8220;featured_event&#8221; or &#8220;mahasangha&#8221;<br \/>\nMy loop below works without these two parameters, but every time I try applying the above two additions, my code breaks or does not work.<\/p>\n<pre><code>&lt;div class=&quot;left-col-event-list&quot;&gt;\n    &lt;h2&gt;Upcoming Events&lt;\/h2&gt;\n&lt;?php\n\t\tglobal $post;\n\n\t\t$list_events = tribe_get_events(array(\n        &#039;eventDisplay&#039;=&gt;&#039;upcoming&#039;,\n        &#039;posts_per_page&#039;=&gt;10,\n        &#039;post_type&#039;=&gt;&#039;tribe_events&#039;,\n        &#039;taxonomy&#039;=&gt;&#039;tribe_events_category&#039;\n\t\t));\n\n\t\tif (count($list_events) == 0) {\n\t\t    echo &#039;&lt;p&gt;No Events at this time.&lt;\/p&gt;&#039;;\n\t\t} else {         \n            \n\t\tforeach($list_events as $post) {\n            \n\t\tsetup_postdata($post);\n            \t\n    ?&gt;\n    \n     &lt;p&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot; class=&quot;title-link&quot;&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/strong&gt;&lt;br&gt;\n\t\t\t\t&lt;strong&gt;Member Group:&lt;\/strong&gt; &lt;?php the_author(); ?&gt;&lt;br&gt;\n                &lt;?php  \n\t\techo &#039;&lt;strong&gt;Starts:&lt;\/strong&gt; &#039; . tribe_get_start_date($post, false, $format = &#039;D, M jS&#039; ) . &#039;&lt;br&gt;&#039;;\n             echo &#039;&lt;strong&gt;Region:&lt;\/strong&gt; &#039; . tribe_get_city( $event_id );\necho &#039;, &#039;;\necho tribe_get_region( $event_id );\n            echo &#039;&lt;\/p&gt;&#039;;\n\t\t}} \/\/endforeach ?&gt;\n           \n\t\t&lt;?php wp_reset_query(); ?&gt;\n            \n&lt;\/div&gt;<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-974807","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 Loop that Displays Month Headers and Conditionally Displays 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\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom Loop that Displays Month Headers and Conditionally Displays Categories -\" \/>\n<meta property=\"og:description\" content=\"I hope it is ok for me to combine two questions in one because they both refer to coding a custom event loop. Thank you for you help ahead of time. 1) How would I write code that puts Month headers in the appropriate location so that a list of events can be separated by [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/\" \/>\n<meta property=\"article:modified_time\" content=\"2015-07-21T14:05:03+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-loop-that-displays-month-headers-and-conditionally-displays-categories\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/\",\"name\":\"Custom Loop that Displays Month Headers and Conditionally Displays Categories -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2015-07-02T19:04:50+00:00\",\"dateModified\":\"2015-07-21T14:05:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-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\":\"Custom Loop that Displays Month Headers and Conditionally Displays 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":"Custom Loop that Displays Month Headers and Conditionally Displays 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\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/","og_locale":"en_US","og_type":"article","og_title":"Custom Loop that Displays Month Headers and Conditionally Displays Categories -","og_description":"I hope it is ok for me to combine two questions in one because they both refer to coding a custom event loop. Thank you for you help ahead of time. 1) How would I write code that puts Month headers in the appropriate location so that a list of events can be separated by [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/","article_modified_time":"2015-07-21T14:05:03+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-loop-that-displays-month-headers-and-conditionally-displays-categories\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/","name":"Custom Loop that Displays Month Headers and Conditionally Displays Categories -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2015-07-02T19:04:50+00:00","dateModified":"2015-07-21T14:05:03+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-categories\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-loop-that-displays-month-headers-and-conditionally-displays-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":"Custom Loop that Displays Month Headers and Conditionally Displays 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\/974807","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\/974807\/revisions"}],"predecessor-version":[{"id":975150,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/974807\/revisions\/975150"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=974807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}