Can't get own scope to work
-
Hi,
1. I followed your solution for generating own scopes with a snippet in functions.php, but the awaited results don’t show up in my events list.
Wanted to show all events in the next 3 month beginning today.The code is:
add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions2',1,2); function my_em_scope_conditions2($conditions, $args){ if( !empty($args['scope']) && $args['scope']=='vorschau' ){ $start_date = date('j-F-Y',current_time('timestamp')); $end_date = date('j-F-Y',strtotime("+3 months", 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; } add_filter( 'em_get_scopes','my_em_scopes2',1,1); function my_em_scopes2($scopes){ $my_scopes = array( 'vorschau' => 'vorschau' ); return $scopes + $my_scopes; }
What’s wrong?
2. What if I want to add another scope (all events from today)? What parts of the snippet must be changed?
Thanks in advance for your help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Can't get own scope to work’ is closed to new replies.