Advertisement
eventsmanager

Prevent recurring events from displaying using [events_list]

Feb 22nd, 2013
354
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. This snippet will add new search attributes to hide recurring events using shortcode [events_list]
  3.  
  4. usage: [events_list hide_recurring=1]
  5. */
  6.  
  7. add_filter('em_events_get_default_search','my_em_styles_get_default_search_hide_recurr',1,2);
  8. function my_em_styles_get_default_search_hide_recurr($searches, $array){
  9. if( !empty($array['hide_recurring']) ){
  10. $searches['hide_recurring'] = $array['hide_recurring'];
  11. }
  12. return $searches;
  13. }
  14.  
  15. add_filter('em_events_get','my_em_hide_recurr',1,2);
  16. function my_em_hide_recurr($events, $args){
  17. if( !empty($args['hide_recurring']) && is_numeric($args['hide_recurring']) && $args['hide_recurring'] > 1 ){
  18. foreach($events as $event_key => $EM_Event){
  19. if ( !empty($EM_Event->recurrence_id) ){
  20. unset($events[$event_key]);
  21. }
  22. }
  23. }
  24. return $events;
  25. }
Advertisement
RAW Paste Data Copied
Advertisement