• Resolved themattsearle

    (@themattsearle)


    I’ve played around lots with different options and can’t seem to get this working.

    I’m trying to use a shortcode to list the upcoming events for this week but I’m having no luck.

    If I use something like:
    [events_list_grouped mode="weekly" limit="10"]#_EVENTLINK - #_EVENTDATES at #_EVENTTIMES.<br />[/events_list_grouped]

    then I get the next 10 events group by the weeks. If I change the limit to 1 then I just get the next event this week, which isn’t what I’m after.

    The number of events in a week will change so it’s not like I can arbitrarily set a limit.

    I tried:
    [events_list scope="future" limit="7"]

    which again just gives me the next 7 events. I also tried adding mode=weekly just as a “maybe this will work!” attempt but got nowhere.

    Is it even possible to just list the events that are coming up in a date range of the next 7 days?

    Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    another way is to create your own event scope and maybe this tutorial can help you out – https://wp-events-plugin.com/tutorials/create-your-own-event-scope/

    Thread Starter themattsearle

    (@themattsearle)

    Many thanks – that’s exactly what I did:

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
        if( !empty($args['scope']) && $args['scope']=='next-seven-days' ){
            $start_date = date('Y-m-d');
            $end_date = date('Y-m-d',strtotime("+7 days"));
            $conditions['scope'] = " (event_start_date BETWEEN CAST('$start_date' AS DATE) AND CAST('$end_date' AS DATE)) OR (event_end_date BETWEEN CAST('$end_date' AS DATE) AND CAST('$start_date' AS DATE))";
        }
        return $conditions;
    }
    
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
        $my_scopes = array(
            'next-seven-days' => 'Next Seven Days'
        );
        return $scopes + $my_scopes;
    }

    I put that in Snippets and it seems to do exactly what we need.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List events for this week’ is closed to new replies.