• Resolved Guenni007

    (@guenni007)


    i have this created to have a list of the current year til today:

    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-year' ){
    		$start_date = date('Y-m-d',strtotime("First day of January", current_time('timestamp')));
    		$end_date = date('Y-m-d',current_time('timestamp'));
    		$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;
    }

    but on that list there are also current events (not only past events) listed.
    Is there a way to have only past events on current years ?
    Thanks

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

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

    (@angelo_nwl)

    it might be your $end_date since it’s using the current_time ? also, you might need 2 part snippet to make this work – https://wp-events-plugin.com/tutorials/create-your-own-event-scope/

    Thread Starter Guenni007

    (@guenni007)

    The problem is that an event has on my page a starting date that is (after beginning) in the past but the event is still active because the event is a long-term exhibition that is still going on.
    How can i avoid that listing. Or in other words how to exclude those events from that list that has a past starting date but still are current events.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘own scope’ is closed to new replies.