Advertisement
eventsmanager

#_CATEGORYNEXTEVENTS limit

Mar 3rd, 2013
470
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This snippet will override default #_CATEGORYNEXTEVENTS placeholder by adding additional search attributes particularly limiting the events list to 3 under single category page.
  3. */
  4. add_filter('em_category_output_placeholder','my_em_placeholder_mod',1,3);
  5. function my_em_placeholder_mod($replace, $EM_Category, $result){
  6. switch( $result ){
  7. case '#_CATEGORYNEXTEVENTS':
  8. $events = EM_Events::get( array('category'=>$EM_Category->term_id, 'scope'=>'future', 'limit'=>3, 'order' => 'ASC', 'orderby' => 'event_name') );
  9. if ( count($events) > 0 ){
  10. $replace = get_option('dbem_category_event_list_item_header_format');
  11. foreach($events as $event){
  12. $replace .= $event->output(get_option('dbem_category_event_list_item_format'));
  13. }
  14. $replace .= get_option('dbem_category_event_list_item_footer_format');
  15. } else {
  16. $replace = get_option('dbem_category_no_events_message');
  17. }
  18. break;
  19. }
  20. return $replace;
  21. }
Advertisement
RAW Paste Data Copied
Advertisement