[Plugin: Events Manager] Creating custom scope for Events widgets
-
I’m trying to create a custom scope to show the events from THIS WEEK in a widget. This Week is not currently an option.
I’ve tried the tutorial at:
https://wp-events-plugin.com/tutorials/create-your-own-event-scope/
but I couldn’t seem to get it to work.Here is the code I altered from that page and put into the functions.php file of my custom theme:
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',current_time('timestamp')); $end_date = date('Y-m-d',strtotime("+6 day", 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_scopes',1,1); function my_em_scopes($scopes){ $my_scopes = array( 'this-week' => 'This Week' ); return $scopes + $my_scopes; }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘[Plugin: Events Manager] Creating custom scope for Events widgets’ is closed to new replies.