{"id":1945814,"date":"2020-02-12T13:48:55","date_gmt":"2020-02-12T18:48:55","guid":{"rendered":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/?post_type=tribe-knowledgebase&#038;p=1945814"},"modified":"2023-02-10T03:26:01","modified_gmt":"2023-02-10T08:26:01","slug":"template-hooks","status":"publish","type":"post","link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/template-hooks\/","title":{"rendered":"Template Hooks"},"content":{"rendered":"\n<p>Every calendar view template has a &#8220;before&#8221; and &#8220;after&#8221; hook that allows you to insert custom HTML either above or below the template, respectively. For example, if you wanted to include a button after the <code>month\/mobile-events.php<\/code> template, we would use the action <code>tribe_template_after_include:events\/v2\/month\/mobile-events<\/code>. Our action would then look something like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action( &#039;tribe_template_after_include:events\/v2\/month\/mobile-events&#039;, function( $file, $name, $template ) {\n  echo &#039;&lt;button&gt;My Button&lt;\/button&gt;&#039;;\n}, 10, 3 );\n<\/pre><\/div>\n\n\n<p>&#8230;where <code>$file<\/code> is a string of the complete template path, <code>$name<\/code> is an array of the parts of the template name, and <code>$template<\/code> is the current instance of the <code>Tribe__Template<\/code> class. You probably won\u2019t need to work with any of these most of the time.<\/p>\n\n\n\n<p>As another example, if you wanted to include a link before the view selector (the template <code>components\/events-bar\/views.php<\/code>), we would use the action <code>tribe_template_before_include:events\/v2\/components\/events-bar\/views<\/code>. Our action would then look something like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_action( &#039;tribe_template_before_include:events\/v2\/components\/events-bar\/views&#039;, function( $file, $name, $template ) {\n  echo &#039;&lt;a href=&quot;#&quot;&gt;My Link&lt;\/a&gt;&#039;;\n}, 10, 3 );\n<\/pre><\/div>\n\n\n<p>These before and after hooks allow users another way to hook into and modify the templates without making changes to the templates themselves.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every calendar view template has a &#8220;before&#8221; and &#8220;after&#8221; hook that allows you to insert custom HTML either above or below the template, respectively. For example, if you wanted to include a button after the month\/mobile-events.php template, we would use the action tribe_template_after_include:events\/v2\/month\/mobile-events. Our action would then look something like this: &#8230;where $file is a&#8230;<\/p>\n","protected":false},"author":3,"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":[59,84],"tags":[],"stellar-product-taxonomy":[161],"class_list":["post-1945814","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing-resources","category-theming-overview","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":59,"label":"PHP &amp; Functions"},{"value":84,"label":"Templating &amp; Layout"}],"stellar-product-taxonomy":[{"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":"Jaime Marchwinski","author_link":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":59,"name":"PHP &amp; Functions","slug":"customizing-resources","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":101,"filter":"raw","term_order":"0","cat_ID":59,"category_count":101,"category_description":"","cat_name":"PHP &amp; Functions","category_nicename":"customizing-resources","category_parent":24},{"term_id":84,"name":"Templating &amp; Layout","slug":"theming-overview","term_group":0,"term_taxonomy_id":84,"taxonomy":"category","description":"","parent":24,"count":59,"filter":"raw","term_order":"0","cat_ID":84,"category_count":59,"category_description":"","cat_name":"Templating &amp; Layout","category_nicename":"theming-overview","category_parent":24}],"tag_info":false,"_links":{"self":[{"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945814","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1945814"}],"version-history":[{"count":1,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945814\/revisions"}],"predecessor-version":[{"id":1956046,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945814\/revisions\/1956046"}],"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=1945814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1945814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1945814"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/staging.theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1945814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}