Show Category pages week views

Home Forums Calendar Products Events Calendar PRO Show Category pages week views

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1385730
    3mediaweb
    Participant

    Is there any way to load Events category pages in week view without editing the main Calendar page layout.? (that’susing Month view)
    I’ve found something for List View: https://theeventscalendar.com/knowledgebase/change-default-categories-view/
    But I want the similar for ‘Week View’. Can anyone please help.?

    Thanks

    #1388771
    Jennifer
    Keymaster

    Hello,

    Sure thing! I modified the snippet in that post for week view. Try adding this to the functions.php file in your child theme:

    /**
    * Redirect event category requests to week view.
    *
    * @param $query
    */
    function use_week_view_for_categories( $query ) {
    // Disregard anything except a main archive query
    if ( is_admin() || ! $query->is_main_query() || ! is_archive() ) return;

    // We only want to catch *event* category requests being issued
    // against something other than week view
    if ( ! $query->get( 'tribe_events_cat' ) ) return;
    if ( tribe_is_week() ) return;

    // Get the term object
    $term = get_term_by( 'slug', $query->get( 'tribe_events_cat' ), Tribe__Events__Main::TAXONOMY );

    // If it's invalid don't go any further
    if ( ! $term ) return;

    // Get the week-view taxonomy link and redirect to it
    header( 'Location: ' . tribe_get_week_permalink( $term->term_id ) );
    exit();
    }

    // Use week view for category requests by hooking into pre_get_posts for event queries
    add_action( 'tribe_events_pre_get_posts', 'use_week_view_for_categories' );

    Let me know how that works for you!

    Thanks,

    Jennifer

    #1404703
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Show Category pages week views’ is closed to new replies.