{"id":1945660,"date":"2020-09-14T13:07:21","date_gmt":"2020-09-14T17:07:21","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/?post_type=tribe-knowledgebase&#038;p=1945660"},"modified":"2026-04-02T17:18:15","modified_gmt":"2026-04-02T21:18:15","slug":"adding-ajax-powered-see-week-links-to-month-view","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/adding-ajax-powered-see-week-links-to-month-view\/","title":{"rendered":"Adding AJAX-Powered &#8220;See Week&#8221; Links to The Events Calendar&#8217;s Month View"},"content":{"rendered":"\n<p>Template and CSS changes are great to start customizing calendar views. However, for more control over functionality, simple overrides just won&#8217;t cut it. The good news is that with the <a href=\"https:\/\/theeventscalendar.com\/getting-started-with-the-new-calendar-views\/\" target=\"_blank\" rel=\"noreferrer noopener\">latest calendar view designs<\/a> in The Events Calendar, it&#8217;s now possible to add more customized JavaScript functionality. Let&#8217;s walk through adding an AJAX-powered link to your view by hooking into the AJAX manager.<\/p>\n\n\n\n<p>Our goal here is to add a link to the left of each row in the calendar&#8217;s month view that takes the user to the calendar&#8217;s week view for that particular week. We want the link to be powered by AJAX so that the switch between views happens without a page refresh. We also want to make sure that these links only show up on the desktop, rather than showing them in the small-screen version of the calendar.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2020\/02\/KB-month-view.png\" alt=\"adding ajax links to month view\" class=\"wp-image-1945662\"\/><figcaption>The red outlines show where we want our links to go.<\/figcaption><\/figure>\n\n\n\n<p>First, we need to <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-template-files-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">override the calendar body template<\/a> from the plugin folder to your theme folder. In other words, located the template source file  (<code>\/wp-content\/plugins\/the-events-calendar\/src\/views\/v2\/month\/calendar-body.php<\/code>) and copy it to your theme folder in a <code>tribe<\/code> folder (<code>[your-theme]\/tribe\/events\/v2\/month\/calendar-body.php<\/code>). <\/p>\n\n\n\n<p>Now we\u2019re going to add the link. Edit the file so it looks like below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;div class=&quot;tribe-events-calendar-month__body&quot; role=&quot;rowgroup&quot;&gt;\n\n  &lt;?php foreach ( array_chunk( $days, 7, true ) as $week ) : ?&gt;\n\n    &lt;div class=&quot;tribe-events-calendar-month__week&quot; role=&quot;row&quot; data-js=&quot;tribe-events-month-grid-row&quot;&gt;\n      &lt;div class=&quot;tribe-events-calendar-month__week-link-wrapper tribe-common-a11y-hidden&quot;&gt;\n        &lt;a class=&quot;tribe-events-calendar-month__week-link&quot; href=&quot;&lt;?php echo tribe_events_get_url( &#x5B; &#039;eventDisplay&#039; =&gt; &#039;week&#039;, &#039;eventDate&#039; =&gt; key( $week ) ] ); ?&gt;&quot; data-js=&quot;tribe-events-view-link&quot;&gt;\n          &lt;?php esc_html_e( &#039;See week&#039;, &#039;your-text-domain&#039; ); ?&gt;\n        &lt;\/a&gt;\n      &lt;\/div&gt;\n\n      &lt;?php foreach ( $week as $day_date =&gt; $day ) : ?&gt;\n        &lt;?php $this-&gt;template( &#039;month\/calendar-body\/day&#039;, &#x5B; &#039;day_date&#039; =&gt; $day_date, &#039;day&#039; =&gt; $day ] ); ?&gt;\n      &lt;?php endforeach; ?&gt;\n   \n    &lt;\/div&gt;\n\n  &lt;?php endforeach; ?&gt;\n\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<p> A couple of things are happening here. First, we\u2019re building the week view URL using the template tag <code><a href=\"https:\/\/docs.theeventscalendar.com\/reference\/functions\/tribe_events_get_url\/\" target=\"_blank\" rel=\"noreferrer noopener\">tribe_events_get_url()<\/a><\/code>. Secondly, and more importantly, we\u2019re hooking into the AJAX manager JavaScript using the attribute <code>data-js=\"tribe-events-view-link\"<\/code> on the link. This tells the AJAX manager to intercept the link click and fetch the next view via AJAX. Note that this only works for views built using <a href=\"https:\/\/theeventscalendar.com\/product\/wordpress-events-calendar\/\" target=\"_blank\" rel=\"noreferrer noopener\">The Events Calendar<\/a> or <a href=\"https:\/\/theeventscalendar.com\/product\/wordpress-events-calendar-pro\/\" target=\"_blank\" rel=\"noreferrer noopener\">Events Calendar Pro<\/a> plugins and will not work for other links. <\/p>\n\n\n\n<p>Now let\u2019s add some styles to the link. Add the following CSS to your <code>styles.css<\/code> file or any stylesheet that will be included on the month view. You can even use a <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-css\/\" target=\"_blank\" rel=\"noreferrer noopener\">custom CSS template for The Events Calendar<\/a> if you&#8217;d like.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\n.tribe-common--breakpoint-medium.tribe-events .tribe-events-calendar-month__week {\n  position: relative;\n}\n\n.tribe-events .tribe-events-calendar-month__week-link-wrapper {\n  border-right: 1px solid #E4E4E4;\n  border-bottom: 1px solid #E4E4E4;\n  height: 100%;\n  position: absolute;\n  right: 100%;\n  text-align: center;\n  top: -1px;\n  transform: rotateZ(180deg);\n  writing-mode: vertical-rl;\n}\n\n.tribe-common--breakpoint-medium.tribe-events .tribe-events-calendar-month__week-link-wrapper {\n  display: block !important;\n  visibility: visible;\n}\n\n.tribe-events .tribe-events-calendar-month__week:last-child .tribe-events-calendar-month__week-link-wrapper {\n  border-top: 1px solid #E4E4E4;\n  height: calc(100% + 1px);\n}\n\n.tribe-events .tribe-events-calendar-month__week-link:hover,\n.tribe-events .tribe-events-calendar-month__week-link:focus {\n  opacity: 0.7;\n}\n<\/pre><\/div>\n\n\n<p>Save your stylesheet and visit month view in your browser. You should see something similar to this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2020\/02\/KB-month-view-with-links.png\" alt=\"adding ajax links to month view\" class=\"wp-image-1945663\"\/><\/figure>\n\n\n\n<p>Horray! While this looks good, what\u2019s even cooler is that when you click on the \u201cSee week\u201d link, you\u2019ll be directed to the week view for that week via AJAX. Congratulations! You\u2019ve just successfully hooked into the AJAX manager and created your own in-view navigation.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"\/knowledgebase\/wp-content\/uploads\/2020\/09\/this-week-link.gif\" alt=\"adding ajax links to month view\" class=\"wp-image-1948123\"\/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Template and CSS changes are great to start customizing calendar views. However, for more control over functionality, simple overrides just won&#8217;t cut it. The good news is that with the latest calendar view designs in The Events Calendar, it&#8217;s now possible to add more customized JavaScript functionality. Let&#8217;s walk through adding an AJAX-powered link to&#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":[24,84],"tags":[20,23,25,58],"stellar-product-taxonomy":[158,161],"class_list":["post-1945660","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing","category-theming-overview","tag-code","tag-css","tag-customizations","tag-php","stellar-product-taxonomy-events-calendar-pro","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":24,"label":"Customizations"},{"value":84,"label":"Templating &amp; Layout"}],"post_tag":[{"value":20,"label":"Code"},{"value":23,"label":"CSS"},{"value":25,"label":"Customizations"},{"value":58,"label":"PHP"}],"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":"Jaime Marchwinski","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":24,"name":"Customizations","slug":"customizing","term_group":0,"term_taxonomy_id":24,"taxonomy":"category","description":"","parent":0,"count":157,"filter":"raw","term_order":"0","cat_ID":24,"category_count":157,"category_description":"","cat_name":"Customizations","category_nicename":"customizing","category_parent":0},{"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":[{"term_id":20,"name":"Code","slug":"code","term_group":0,"term_taxonomy_id":20,"taxonomy":"post_tag","description":"","parent":0,"count":19,"filter":"raw","term_order":"0"},{"term_id":23,"name":"CSS","slug":"css","term_group":0,"term_taxonomy_id":23,"taxonomy":"post_tag","description":"","parent":20,"count":33,"filter":"raw","term_order":"0"},{"term_id":25,"name":"Customizations","slug":"customizations","term_group":0,"term_taxonomy_id":25,"taxonomy":"post_tag","description":"","parent":0,"count":102,"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":78,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1945660"}],"version-history":[{"count":2,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945660\/revisions"}],"predecessor-version":[{"id":1968427,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1945660\/revisions\/1968427"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1945660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1945660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1945660"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1945660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}