• I usually use the shortcode [events_list scope=”today”] to display all the events of the current day on a page. If I want to automatically display all the events for this weekend on a page, what would the shortcode be that I should use? And the shortcode to display all the events for this month?”

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Here’s some documentation on how to create custom scopes like “this-weekend” or “this-month”: https://wp-events-plugin.com/documentation/tutorials/create-your-own-event-scope/

    It would look something like this:

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args) {
    if (!empty($args['scope'])) {
    $set_scope = false;
    if( $args['scope']=='this-weekend' ) {
    $start_date = date('Y-m-d', strtotime('next Saturday'));
    $end_date = date('Y-m-d', strtotime('next Sunday'));
    $set_scope = true;

    }
    else if( $args['scope'] == 'this-month' ){
    $start_date = date('Y-m-d', strtotime('first day of this Month'));
    $end_date = date('Y-m-d', strtotime('last day of this Month'));
    $set_scope = true;
    }
    if ( $set_scope == true ) {
    $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( 'this-weekend' => 'This weekend', 'next-month' => 'This Month' );
    return $scopes + $my_scopes;
    }

    After that you can use the following shortcodes:

    [events_list scope="this-weekend"]
    [events_list scope="this-month"]
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.