Ryan Duval

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • in reply to: 404 page not found on all venue pages #1259585
    Ryan Duval
    Participant

    Thanks Geoff & the coding staff, that seemed to do the trick!
    Would not have figured that one out on my own.

    cheers,
    Ryan

    in reply to: 404 page not found on all venue pages #1258717
    Ryan Duval
    Participant

    Hi Geoff,
    I downgraded the event calendar plugin to version 4.2.7, so now my Event Calendar plugins are in the 4.2._ versions, but still all of my venue pages go to a 404 page. I checked through any custom code I added in the child theme, and was actually able to narrow down the problem to this bit of code I added in functions.php:

    /** from https://theeventscalendar.com/support/forums/topic/how-to-hide-past-events/  **/
    add_filter('tribe_events_pre_get_posts', 'filter_tribe_all_occurences', 100);
    
    function filter_tribe_all_occurences ($wp_query) {
            if ( !is_admin() )  {
     
                    $new_meta = array();
                    $today = new DateTime();
                    $start_date =  tribe_get_start_date( null, false, 'Y-m-d H:i:s' ); // 'Y/m/d'
                    $today->setTimezone(new DateTimeZone('America/Los_Angeles'));
    
                    //-RD display current events where start date is less than one week before today
                    $week_past_start_date = date('Y-m-d H:i:s', strtotime($start_date. ' - 7 days'));
    
                    // Join with existing meta_query
                    if(is_array($wp_query->meta_query))
                            $new_meta = $wp_query->meta_query;
     
                    // Add new meta_query, select events ending from now forward
                    $new_meta[] = array(
                            'key' =>  _EventStartDate,
                            'type' => 'DATETIME',
                            'compare' => '>=',
                            'value' => $week_past_start_date
                            // original code:  'value' => $today->format('Y-m-d H:i:s') 
                    );
                    $wp_query->set( 'meta_query', $new_meta );
            }
            return $wp_query;
    } 

    I do need the functionality this code provides (it hides events that are ongoing, but already started over a week ago), but it appears that commenting out this code makes the venue pages appear just fine. I’m not sure why this would impact the venue pages, but somehow it does.

    Is there a better way to achieve my goal of hiding currently-in-process events that began over a week ago, that won’t cause all the venue pages to show 404 not found?

    thanks,
    Ryan

    • This reply was modified 7 years, 1 month ago by Ryan Duval.
    in reply to: 404 page not found on all venue pages #1257960
    Ryan Duval
    Participant

    Hi Geoff,
    Thanks for the help- I think the best way for me at the moment would be to downgrade all of my Event Calendar plugins to a compatible version with my currently working theme. If you can point me in the right direction to do that without messing up currently existing events, I’d really appreciated it!

    in reply to: How to limit widget events by date #1131720
    Ryan Duval
    Participant

    Hi Nico,
    Thanks for the tip. Unfortunately when I add the following code to my functions.php file,

    function tribe_custom_list_widget_events() {
            $today = date( 'Y-m-d' );
    	$args =  array( 'start_date' => $today ); 
    	$posts = tribe_get_events( array( $args ) );
    	return $posts;	
    } 
    add_filter( 'tribe_get_list_widget_events', 'tribe_custom_list_widget_events' );

    the page in question displays all events- even those that have passed.
    To clarify my setup, I’m using the pro shortcode to display events grouped by tag. For example, one block on the page has:

    [tribe_events_list tags=”IMOD” venue=”yes”]

    The other blocks are similar, just with different tags. But when I enable the code in functions.php it seems to override any of the filters in the shortcode and just shows all events.

    It feels like this should be the right direction because the events are called in pro/widgets/list-widget.php:

    // Retrieves the posts used in the List Widget loop.
    $posts = tribe_get_list_widget_events();

    So logically if tribe_get_list_widget_events(); only returns posts whose start date is after today, it seems like it should work, but for some reason it’s displaying all events… Not sure what I’m doing wrong.

    Ryan Duval
    Participant

    Hi Cliff,
    thanks for the reply.
    Actually, what I’m trying to do pertains more to the list widget and Photo View where we show all ‘upcoming’ events. I’d like to show events that begin after todays date.
    For example:

    3 events from February 1 – 15
    2 events from today, Feb 9 – 29
    10 future events starting after today

    I would like the list widget and photo view to show only the 2 events starting today, and the 10 events starting after today, but to NOT display the 3 events that STARTED BEFORE todays date. Currently, it will show any event who’s END DATE is after todays date.

    I realize this may not be an option as a setting, but perhaps there’s a place in the code where I could make this customization? I haven’t been able to find it so far…

Viewing 5 posts - 1 through 5 (of 5 total)