eventsmanager

Filter events listing page by category globally

Aug 10th, 2018
213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Filter default events listing page by events category globally
  3. Where 3 is the events category id
  4. */
  5. function my_em_default_category( $defaults ){
  6.  
  7. if ( is_array($defaults['category']) && !empty($defaults['category']) ){
  8. array_push( $defaults['category'], 3 );
  9. }
  10. else if ( !is_array($defaults['category']) && !empty($defaults['category']) ){
  11. $defaults['category'] .= ",3";
  12. }
  13. else{
  14. $defaults['category'] = 3;
  15. }
  16.  
  17. return $defaults;
  18. }
  19. add_filter('em_events_get_default_search','my_em_default_category',100,1);
RAW Paste Data