Advertisement
eventsmanager

Count Events Per Location

Feb 22nd, 2013
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. /**
  2. This snippet will add new placeholder to display how many upcoming events
  3. this location has.
  4. */
  5. function em_location_event_count($replace, $EM_Location, $result){
  6. global $wp_query, $wp_rewrite;
  7. switch( $result ){
  8. case '#_LOCATIONEVENTCOUNT':
  9. $replace = "0";
  10. $events = EM_Events::get(array('location'=>$EM_Location->location_id,'scope'=>'future'));
  11. if ( count($events) > 0 ){
  12. $replace = count($events);
  13. }
  14. $replace = "There are ".$replace." events in this location";
  15. break;
  16. }
  17. return $replace;
  18. }
  19. add_filter('em_location_output_placeholder','em_location_event_count',1,3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement