Resolving "Exclude Current Event from Listing"
-
Hi,
I have a solution to “Exclude Current Event from Listing”:
http://wordpress.org/support/topic/exclude-current-event-from-listing?replies=7
However this entry is marked as resolved, so here I add a solution in a new thread:
To allow to exclude events using post__not_in arg in a search, I added these 2 filters:
add_filter('em_events_get_default_search', 'gd_em_events_get_default_search_exclude_post_id', 10, 3); function gd_em_events_get_default_search_exclude_post_id($defaults, $array, $super_defaults) { if (!empty($array['post__not_in'])) { $defaults['post__not_in'] = $array['post__not_in']; } return $defaults; } add_filter('em_events_build_sql_conditions', 'gd_em_events_build_sql_conditions_exclude_post_id', 10, 2); function gd_em_events_build_sql_conditions_exclude_post_id($conditions, $args) { if( !empty($args['post__not_in'])){ if( is_array($args['post__not_in']) ){ $conditions['post__not_in'] = "(".EM_EVENTS_TABLE.".post_id NOT IN (".implode(',',$args['post__not_in'])."))"; }else{ $conditions['post__not_in'] = "(".EM_EVENTS_TABLE.".post_id!={$args['post__not_in']})"; } } return $conditions; }
Btw, @marcus, maybe you want to add this exclude arg in the code? I think it might be very helpful.
Cheers,
Leo
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Resolving "Exclude Current Event from Listing"’ is closed to new replies.