WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] show all days of the current week (4 posts)

  1. solomax
    Member
    Posted 2 years ago #

    Hi I am stuck with my query, please help.

    I am using the free version. Using version 5.1.4.3

    What I want is to see all the days of the current week. But now my querie doesnt show the days before today only the days left in this week. e.g. on friday the days monday, tuesday and wednesday, thursday aren't shown

    In the page I use the following shortcode:

    [events_list category="30,31,33" scope="this-week" ]

    i made the following query:

    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'] == 'this-week' ){
    $week_number = date('w');
    $start_date = date("Y-m-d",time() - ($week_number - 1)*ONE_DAY);
    $end_date = date('Y-m-d', strtotime('Next Sunday', time()));
    $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;
    }

    please help
    check http://www.vanrheenensport.nl/budo-sport-almere/pencak-silat-almere/

    the orange box holds the result of the query

    thanks,

    fabian

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 2 years ago #

    Hi,

    sorry for not giving an update; I'm going to try this out today and update you.

  3. agelonwl
    Member
    Posted 2 years ago #

    Hi,

    can you try these code snippet and give some feedback?

    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'] == 'this-week' ){
    
    		$start_date = date("Y-m-d", strtotime(date("Y").'W'.date('W')."1"));
    		$end_date = date("Y-m-d", strtotime(date("Y").'W'.date('W')."7"));
    
    		$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;
    }
  4. aponeurotica
    Member
    Posted 2 years ago #

    @agelonwl:
    I don't know if your snippet worked for @solomax, but it was EXACTLY what I have been struggling to figure out. Thank you so much! Worked perfectly.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic