Show Specific Month on Events Calendar

Home Forums Calendar Products Events Calendar PRO Show Specific Month on Events Calendar

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1316506
    Laura Luttrell
    Participant

    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”.

    #1316545
    Laura Luttrell
    Participant

    Note 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.

    #1316951
    Courtney
    Member

    Hello 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 🙂

    #1317012
    Laura Luttrell
    Participant

    Thanks Courtney. Unfortunately switching the default date setting to ‘2017-08’ does not fix the problem.

    Bruce

    #1317064
    Courtney
    Member

    Hello 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 🙂

    #1317103
    Laura Luttrell
    Participant

    I 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.

    #1317377
    Courtney
    Member

    Hello 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 🙂

    #1317522
    Laura Luttrell
    Participant

    That 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.

    #1317564
    Courtney
    Member

    Great Bruce, I’m glad your site is working now 🙂

    Let us know if you need further help.

    Thanks
    Courtney 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Show Specific Month on Events Calendar’ is closed to new replies.