{"id":1896496,"date":"2019-10-18T13:19:16","date_gmt":"2019-10-18T17:19:16","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/showing-events-and-venues-in-breadcrumbs-2\/"},"modified":"2020-03-04T11:30:48","modified_gmt":"2020-03-04T16:30:48","slug":"showing-events-and-venues-in-breadcrumbs","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/showing-events-and-venues-in-breadcrumbs\/","title":{"rendered":"Include Events and Venues in Breadcrumb Navigation"},"content":{"rendered":"\n<p>The Events Calendar comes with some&nbsp;built-in conditionals that can be very useful when customizing your templates. Recently, a user asked why events were not showing up correctly in his breadcrumbs.<\/p>\n\n\n\n<p>Unless your breadcrumb code is checking for custom taxonomies, it&#8217;s not going to know what to do with events and venues. Most breadcrumb plugins use a mix of conditionals to determine what to show, and often custom taxonomies don&#8217;t make it into the mix.&nbsp;If you want to show breadcrumbs with events, you&#8217;ll need to change that.<\/p>\n\n\n\n<p>To do so, copy the snippet below into your theme&#8217;s functions.php file. This code uses our&nbsp;built-in conditionals to handle events and venues.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>You can use it verbatim- just add&nbsp;<strong>tribe_breadcrumbs();<\/strong> to your page template.<\/li><li>If you use a theme framework, add an action hook wherever you want the breadcrumbs to appear: <strong>add_action(&#8216;hook_name&#8217;,&#8217;tribe_breadcrumbs&#8217;);<\/strong><\/li><\/ul>\n\n\n\n<p>This code is based on the <a href=\"http:\/\/diythemes.com\/thesis\/rtfm\/breadcrumbs-without-plugins\/\" target=\"_blank\" rel=\"noopener noreferrer\">Thesis Breadcrumbs Without Plugins<\/a> code.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n\/\/ Check if page is direct child\nfunction is_child( $page_id ) {\n\tglobal $post;\n\tif( is_page() &amp;&amp; ($post-&gt;post_parent != &#039;&#039;) ) {\n\t\treturn true;\n\t} else {\n\t\treturn false;\n\t}\n}\n\n\/\/ Breadcrumb Logic\nfunction tribe_breadcrumbs() {\n\tglobal $post;\n\n\t$separator = &quot; &amp;raquo; &quot;;\n\t\n\techo &#039;&lt;div class=&quot;tribe-breadcrumbs&quot;&gt;&#039;;\n\techo &#039;&lt;a href=&quot;&#039; . get_option(&#039;home&#039;) . &#039;&quot;&gt;&#039; . bloginfo( &#039;name&#039; ) . &#039;&lt;\/a&gt;&#039;;\n\n\tif( tribe_is_month() &amp;&amp; !is_tax() ) { \/\/ The Main Calendar Page\n\t\techo $separator;\n\t\techo &#039;The Events Calendar&#039;;\n\t} elseif( tribe_is_month() &amp;&amp; is_tax() ) { \/\/ Calendar Category Pages\n\t\tglobal $wp_query;\n\t\t\n\t\t$term_slug = $wp_query-&gt;query_vars&#x5B;&#039;tribe_events_cat&#039;];\n\t\t$term = get_term_by(&#039;slug&#039;, $term_slug, &#039;tribe_events_cat&#039;);\n\t\tget_term( $term_id, &#039;tribe_events_cat&#039; );\n\t\t$name = $term-&gt;name;\n\t\techo $separator;\n\t\techo &#039;&lt;a href=&quot;&#039;.tribe_get_events_link().&#039;&quot;&gt;Events&lt;\/a&gt;&#039;;\n\t\techo $separator;\n\t\techo $name;\n\t} elseif( tribe_is_event() &amp;&amp; !tribe_is_day() &amp;&amp; !is_single() ) { \/\/ The Main Events List\n\t\techo $separator;\n\t\techo &#039;Events List&#039;;\n\t} elseif( tribe_is_event() &amp;&amp; is_single() ) { \/\/ Single Events\n\t\techo $separator;\n\t\techo &#039;&lt;a href=&quot;&#039;.tribe_get_events_link().&#039;&quot;&gt;Events&lt;\/a&gt;&#039;;\n\t\techo $separator;\n\t\tthe_title();\n\t} elseif( tribe_is_day() ) { \/\/ Single Event Days\n\t\tglobal $wp_query;\n\n\t\techo $separator;\n\t\techo &#039;&lt;a href=&quot;&#039;.tribe_get_events_link().&#039;&quot;&gt;Events&lt;\/a&gt;&#039;;\n\t\techo $separator;\n\t\techo &#039;Events on: &#039; . date(&#039;F j, Y&#039;, strtotime( $wp_query-&gt;query_vars&#x5B;&#039;eventDate&#039;]) );\n\t} elseif( tribe_is_venue() ) { \/\/ Single Venues\n\t\techo $separator;\n\t\techo &#039;&lt;a href=&quot;&#039;.tribe_get_events_link().&#039;&quot;&gt;Events&lt;\/a&gt;&#039;;\n\t\techo $separator;\n\t\tthe_title();\n\t} elseif ( is_category() || is_single() ) {\n\t\techo $separator;\n\t\tthe_category(&#039; &amp;bull; &#039;);\n\n\t\tif ( is_single() ) {\n\t\t\techo &#039; &#039;.$separator.&#039; &#039;;\n\t\t\tthe_title();\n\t\t}\n\t} elseif ( is_page() ) {\n\t\tif( is_child(get_the_ID()) ) {\n\t\t\techo $separator;\n\t\t\techo &#039;&lt;a href=&quot;&#039; . get_permalink( $post-&gt;post_parent ) . &#039;&quot;&gt;&#039; . get_the_title( $post-&gt;post_parent ) . &#039;&lt;\/a&gt;&#039;;\n\t\t\techo $separator;\n\t\t\techo the_title();\n\t\t} else {\n\t\t\techo $separator;\n\t\t\techo the_title();\n\t\t}\n\t} elseif (is_search()) {\n\t\techo $separator.&#039;Search Results for... &#039;;\n\t\techo &#039;&quot;&lt;em&gt;&#039;;\n\t\techo the_search_query();\n\t\techo &#039;&lt;\/em&gt;&quot;&#039;;\n\t}\n\techo &#039;&lt;\/div&gt;&#039;;\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>The Events Calendar comes with some&nbsp;built-in conditionals that can be very useful when customizing your templates. Recently, a user asked why events were not showing up correctly in his breadcrumbs. Unless your breadcrumb code is checking for custom taxonomies, it&#8217;s not going to know what to do with events and venues. Most breadcrumb plugins use&#8230;<\/p>\n","protected":false},"author":2,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[79],"tags":[25,58,96],"stellar-product-taxonomy":[158,161],"class_list":["post-1896496","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-snippets","tag-customizations","tag-php","tag-venues","stellar-product-taxonomy-events-calendar-pro","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":79,"label":"Snippets"}],"post_tag":[{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"},{"value":96,"label":"Venues"}],"stellar-product-taxonomy":[{"value":158,"label":"Events Calendar Pro"},{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"zach","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/zach\/"},"comment_info":0,"category_info":[{"term_id":79,"name":"Snippets","slug":"snippets","term_group":0,"term_taxonomy_id":79,"taxonomy":"category","description":"","parent":0,"count":136,"filter":"raw","term_order":"0","cat_ID":79,"category_count":136,"category_description":"","cat_name":"Snippets","category_nicename":"snippets","category_parent":0}],"tag_info":[{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":177,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":128,"filter":"raw","term_order":"0"},{"term_id":96,"name":"Venues","slug":"venues","term_group":0,"term_taxonomy_id":96,"taxonomy":"post_tag","description":"","parent":0,"count":9,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1896496"}],"version-history":[{"count":1,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896496\/revisions"}],"predecessor-version":[{"id":1956320,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1896496\/revisions\/1956320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1896496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1896496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1896496"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1896496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}