function my_build_sql_conditions( $conditions, $args ){ $events_table = EM_EVENTS_TABLE; $locations_table = EM_LOCATIONS_TABLE; if( true == $args['eventful'] ){ $conditions['eventful'] = "{$events_table}.location_id IS NOT NULL"; }elseif( true == $args['eventless'] ){ $conditions['eventless'] = "{$events_table}.location_id IS NULL"; if( !empty($conditions['scope']) ) unset($conditions['scope']); //scope condition would render all queries return no results } return $conditions; } add_filter( 'em_locations_build_sql_conditions', 'my_build_sql_conditions', 100, 2 );