{"id":1962675,"date":"2024-08-28T06:18:42","date_gmt":"2024-08-28T10:18:42","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/?p=1962675"},"modified":"2024-08-28T06:18:44","modified_gmt":"2024-08-28T10:18:44","slug":"remove-next-months-dates-from-current-month-in-mini-calendar-view","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/remove-next-months-dates-from-current-month-in-mini-calendar-view\/","title":{"rendered":"Remove Next Month&#8217;s Dates from Current Month in Mini Calendar View"},"content":{"rendered":"\n<p>Sometimes the next month&#8217;s first few days appear on the Mini Calendar View calendar, depending on how each month is structured. If you&#8217;d like, you can remove these dates by adding a PHP snippet on your site and then using custom CSS added to your theme&#8217;s stylesheet. We&#8217;ll provide you with the snippets you need to make this happen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"465\" src=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/08\/mini_month_view.png\" alt=\"\" class=\"wp-image-1962677\" srcset=\"https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/08\/mini_month_view.png 567w, https:\/\/images.theeventscalendar.com\/kb\/uploads\/2024\/08\/mini_month_view-300x246.png 300w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-php-snippet\">The PHP snippet<\/h2>\n\n\n\n<p>First, you&#8217;ll need to add the following PHP snippet on your functions.php theme file or using the <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Code Snippets<\/a> plugin:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter(\n\t&#039;tribe_events_views_v2_view_month_template_vars&#039;,\n\tfunction( $template_vars, $view ) {\n\t\t\/\/ current time.\n\t\t$now = Tribe__Date_Utils::build_date_object( $template_vars&#x5B;&#039;now&#039;] );\n\t\t\/\/ requested date - for month view this is the first of the month.\n\t\t$request_date = $template_vars&#x5B;&#039;request_date&#039;];\n\t\t\n\t\t\/\/ if requested date isn&#039;t the same as the current date\n\t\tif ( $now-&gt;format( &#039;Y-m-d&#039; ) !== $request_date-&gt;format( &#039;Y-m-d&#039; ) ) {\n\t\t\t\/\/ pass the requested date as the current date\n\t\t\t$template_vars&#x5B;&#039;today_date&#039;] = $template_vars&#x5B;&#039;request_date&#039;]-&gt;format( &#039;Y-m-d&#039; );\n\t\t}\n\t\t\n\t\treturn $template_vars;\n\t},\n\t10,\n\t2\n);\n<\/pre><\/div>\n\n\n<p>This snippet is needed to make sure that hiding the respective days works in other months as well, not only the current one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-template-override\">The Template Override<\/h2>\n\n\n\n<p>Create a <strong>mobile-day.php<\/strong> file on your <code>\/wp-content\/themes\/[your-theme or child-theme folder]\/tribe\/events\/v2\/month\/mobile-events<\/code> folder (you may need to create the folders if you haven&#8217;t already done so). After that, place the following as the content of the mobile-day.php file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\n&lt;?php\nuse Tribe__Date_Utils as Dates;\n\n$events = ! empty( $day&#x5B;&#039;events&#039;] ) ? $day&#x5B;&#039;events&#039;] : &#x5B;];\nif ( ! empty( $day&#x5B;&#039;multiday_events&#039;] ) ) {\n\t$events = array_filter( array_merge( $day&#x5B;&#039;multiday_events&#039;], $events ) );\n}\n$mobile_day_id = &#039;tribe-events-calendar-mobile-day-&#039; . $day&#x5B;&#039;year_number&#039;] . &#039;-&#039; . $day&#x5B;&#039;month_number&#039;] . &#039;-&#039; . $day&#x5B;&#039;day_number&#039;];\n\n$classes = &#x5B; &#039;tribe-events-calendar-month-mobile-events__mobile-day&#039; ];\n\nif ( $today_date === $day_date ) {\n\t$classes&#x5B;] = &#039;tribe-events-calendar-month-mobile-events__mobile-day--show&#039;;\n}\n?&gt;\n\n&lt;div &lt;?php tribe_classes( $classes ); ?&gt; id=&quot;&lt;?php echo sanitize_html_class( $mobile_day_id ); ?&gt;&quot;&gt;\n\n\t&lt;?php if ( count($events) ) : ?&gt;\n\n\t\t&lt;?php foreach ( $events as $event ) : ?&gt;\n\t\t\t&lt;?php \n\t\t\t\t$first_day_of_month = date( &#039;Y-m-d&#039;, strtotime ( &#039;first day of&#039; . $today_date ) );\n\t\t\t\t\n\t\t\t\t$end_day_of_month = date( &#039;Y-m-d&#039;, strtotime( &#039;last day of&#039; . $today_date ) );\n\t\t\t\t\n\t\t\t\tif ( $event-&gt;dates-&gt;start-&gt;format (&#039;Y-m-d&#039;) &lt; $first_day_of_month || $event-&gt;dates-&gt;start-&gt;format (&#039;Y-m-d&#039;) &gt; $end_day_of_month ) { \n\t\t\t\t\tcontinue;\n\t\t\t\t}\t\n\t\t\t\telse {\t\t\t\n\t\t\t?&gt;\n\n\t\t\t&lt;?php $event_date = $event-&gt;dates-&gt;start-&gt;format( Dates::DBDATEFORMAT ); ?&gt;\n\n\t\t\t&lt;?php $this-&gt;template( &#039;month\/mobile-events\/mobile-day\/day-marker&#039;, &#x5B; &#039;events&#039; =&gt; $events, &#039;event&#039; =&gt; $event, &#039;request_date&#039; =&gt; $day_date ] ); ?&gt;\n\n\t\t\t&lt;?php $this-&gt;setup_postdata( $event ); ?&gt;\n\n\t\t\t&lt;?php $this-&gt;template( &#039;month\/mobile-events\/mobile-day\/mobile-event&#039;, &#x5B; &#039;event&#039; =&gt; $event ] ); ?&gt;\n\n\t\t\t&lt;?php } ?&gt;\n\n\t\t&lt;?php endforeach; ?&gt;\n\n\t\t&lt;?php $this-&gt;template( &#039;month\/mobile-events\/mobile-day\/more-events&#039;, &#x5B; &#039;more_events&#039; =&gt; $day&#x5B;&#039;more_events&#039;], &#039;more_url&#039; =&gt; $day&#x5B;&#039;day_url&#039;] ] ); ?&gt;\n\n\t&lt;?php else : ?&gt;\n\n\t\t&lt;?php\n\t\t$this-&gt;template(\n\t\t\t&#039;components\/messages&#039;,\n\t\t\t&#x5B;\n\t\t\t\t&#039;classes&#039; =&gt; &#x5B; &#039;tribe-events-header__messages--mobile&#039;, &#039;tribe-events-header__messages--day&#039; ],\n\t\t\t\t&#039;messages&#039; =&gt; $mobile_messages,\n\t\t\t]\n\t\t);\n\t\t?&gt;\n\n\t&lt;?php endif; ?&gt;\n&lt;\/div&gt;\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-css-snippet\">The CSS Snippet<\/h2>\n\n\n\n<p>There are a few different ways to add custom CSS to your WordPress site. For more information on how to do that, check out the <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/customizing-css\/\" target=\"_blank\" rel=\"noreferrer noopener\">Customizing CSS<\/a> knowledge base article.<\/p>\n\n\n\n<p>To remove the next and previous month&#8217;s dates from the calendar, use this CSS snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\n.tribe-events-view--shortcode div.tribe-events-calendar-month__day--next-month {\n  visibility: hidden !important;\n}\n<\/pre><\/div>\n\n\n<p>To remove the previous month&#8217;s dates from the calendar, use this snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\n.tribe-events-view--shortcode div.tribe-events-calendar-month__day--past-month {\n    visibility: hidden !important;\n}\n<\/pre><\/div>\n\n\n<p>And, to remove both the previous month and upcoming month dates from the calendar, use this snippet:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\n.tribe-events-view--shortcode div.tribe-events-calendar-month__day--next-month,\n.tribe-events-view--shortcode div.tribe-events-calendar-month__day--past-month  {    \n     visibility: hidden !important;\n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Sometimes the next month&#8217;s first few days appear on the Mini Calendar View calendar, depending on how each month is structured. If you&#8217;d like, you can remove these dates by adding a PHP snippet on your site and then using custom CSS added to your theme&#8217;s stylesheet. We&#8217;ll provide you with the snippets you need&#8230;<\/p>\n","protected":false},"author":63,"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":[116,24],"tags":[23,25],"stellar-product-taxonomy":[161],"class_list":["post-1962675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-styling","category-customizing","tag-css","tag-customizations","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":116,"label":"CSS &amp; Styling"},{"value":24,"label":"Customizations"}],"post_tag":[{"value":23,"label":"CSS"},{"value":25,"label":"Customizations"}],"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":"Tristan","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/tristan\/"},"comment_info":0,"category_info":[{"term_id":116,"name":"CSS &amp; Styling","slug":"css-styling","term_group":0,"term_taxonomy_id":116,"taxonomy":"category","description":"","parent":24,"count":40,"filter":"raw","term_order":"0","cat_ID":116,"category_count":40,"category_description":"","cat_name":"CSS &amp; Styling","category_nicename":"css-styling","category_parent":24},{"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}],"tag_info":[{"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"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1962675","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1962675"}],"version-history":[{"count":5,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1962675\/revisions"}],"predecessor-version":[{"id":1962694,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1962675\/revisions\/1962694"}],"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=1962675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1962675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1962675"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1962675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}