Home › Forums › Calendar Products › Events Calendar PRO › Show Specific Month on Events Calendar
- This topic has 9 replies, 2 voices, and was last updated 6 years, 9 months ago by Laura Luttrell.
-
AuthorPosts
-
July 5, 2017 at 3:20 pm #1316506Laura LuttrellParticipant
We have Events Calendar Pro installed and I am following the directions on this page https://theeventscalendar.com/knowledgebase/set-calendar-to-show-specific-month/ to have the calendar show a specific month but while the calendar claims to be showing the month we want it to show (August 2017) it’s actually showing the current month (July 2017), just with a heading above that says “Events for August 2017.” And at the below the calendar it shows July and September links as if the calendar month being shown were August, but it’s not. The only change I made to the calendar was to replace “2015-10-01” with “2017-08-01”.
July 5, 2017 at 5:23 pm #1316545Laura LuttrellParticipantNote that where I said “The only change I made to the calendar was to replace ‘2015-10-01’ with ‘2017-08-01′” what I meant is that this is the only change I made to the code supplied on the page I linked to in my previous post.
July 6, 2017 at 9:51 am #1316951CourtneyMemberHello Rupert
It is working on your site in list view, but hiding events in month view. To resolve this, change the date formatting like this:
$default_date = '2017-05';
Let me know if this works for you.
Thanks
Courtney 🙂July 6, 2017 at 10:59 am #1317012Laura LuttrellParticipantThanks Courtney. Unfortunately switching the default date setting to ‘2017-08’ does not fix the problem.
Bruce
July 6, 2017 at 12:24 pm #1317064CourtneyMemberHello Bruce
I have tested the following code using Twenty Seventeen https://wordpress.org/themes/twentyseventeen/ and it worked in month view:
/** * Sets the default date for event queries. * * Expects to be called during tribe_events_pre_get_posts. Note that this * function modifies $_REQUEST - this is needed for consistency because * various parts of TEC inspect that array directly to determine the current * date. * * @param WP_Query $query */ function tribe_force_event_date( WP_Query $query ) { // Don't touch single posts or queries other than the main query if ( ! $query->is_main_query() || is_single() ) { return; } // If a date has already been set by some other means, bail out if ( strlen( $query->get( 'eventDate' ) ) || ! empty( $_REQUEST['tribe-bar-date'] ) ) { return; } // Change this to whatever date you prefer $default_date = '2017-08'; // Use the preferred default date $query->set( 'eventDate', $default_date ); $query->set( 'start_date', $default_date ); $_REQUEST['tribe-bar-date'] = $default_date; } add_action( 'tribe_events_pre_get_posts', 'tribe_force_event_date' );
Can you test this with the Twenty Seventeen https://wordpress.org/themes/twentyseventeen/ or other default theme as well?
Thanks
Courtney 🙂July 6, 2017 at 1:35 pm #1317103Laura LuttrellParticipantI just uncovered another aspect of this issue. The code is working fine on the main calendar page. The issue arises when then calendar is displayed embedded in another page using the shortcode [tribe_events]. I confirmed that the problem still exists when using the twentyseventeen theme.
July 7, 2017 at 8:18 am #1317377CourtneyMemberHello Bruce
On https://theeventscalendar.com/knowledgebase/embedding-calendar-views-tribe_events-shortcode/ we show shortcode for displaying an exact month:
[tribe_events view="month" date="2016-08"]
Can you test a similar code on your site to see if that works for your needs?
Thanks
Courtney 🙂July 7, 2017 at 10:46 am #1317522Laura LuttrellParticipantThat worked. Thank you!
But as an FYI: If I put in “2016-08” (August last year) the calendar displays last year’s August events as it should but the heading above the calendar says “Events for August 2017.” This is not a problem for us, at least at this time, but it does appear to be a bug.
July 7, 2017 at 11:28 am #1317564CourtneyMemberGreat Bruce, I’m glad your site is working now 🙂
Let us know if you need further help.
Thanks
Courtney 🙂 -
AuthorPosts
- The topic ‘Show Specific Month on Events Calendar’ is closed to new replies.