Support » Plugin: Events Manager » [Plugin: Events Manager] show all days of the current week

  • Resolved solomax


    Hi I am stuck with my query, please help.

    I am using the free version. Using version

    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

    the orange box holds the result of the query



Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

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


    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;

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] show all days of the current week’ is closed to new replies.