Title: Custom Scope
Last modified: July 24, 2017

---

# Custom Scope

 *  Resolved [wordpress1992](https://wordpress.org/support/users/adgardner13/)
 * (@adgardner13)
 * [9 years ago](https://wordpress.org/support/topic/custom-scope/)
 * I have created a custom scope for next 28 days and this works fine. But I would
   also like to create another scope for the next 56 days and I am unable to create
   this additional function without receiving 500 internal error, any tips?
 * This is the existing function
 *     ```
       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']=='28days' ){
       		$start_date = date('Y-m-d',current_time('timestamp'));
       		$end_date = date('Y-m-d',strtotime("+28 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(
       		'28days' => 'Next 28 Days'
       	);
       	return $scopes + $my_scopes;
       }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [wordpress1992](https://wordpress.org/support/users/adgardner13/)
 * (@adgardner13)
 * [9 years ago](https://wordpress.org/support/topic/custom-scope/#post-9346735)
 * Just an update, I now have two different scopes, that work on separate pages 
   but not together on the same page. Is it possible to run the query on the same
   page?
 * I hope this makes sense
 *  Thread Starter [wordpress1992](https://wordpress.org/support/users/adgardner13/)
 * (@adgardner13)
 * [9 years ago](https://wordpress.org/support/topic/custom-scope/#post-9346739)
 * Sorted now
 *  [timafeo](https://wordpress.org/support/users/timafeo/)
 * (@timafeo)
 * [9 years ago](https://wordpress.org/support/topic/custom-scope/#post-9356646)
 * Could you post how you fixed the issue? I am also interested to learn.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom Scope’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [timafeo](https://wordpress.org/support/users/timafeo/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/custom-scope/#post-9356646)
 * Status: resolved