Advertisement
postoy

Upcoming Events Query for WP All-in-One Event Calendar

Aug 29th, 2012
1,822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. global $ai1ec_calendar_helper;
  4. global $ai1ec_events_helper;
  5.  
  6. // Get localized time
  7. $timestamp = $ai1ec_events_helper->gmt_to_local( time() );
  8. $events_per_page = 3;
  9.  
  10. // Set $limit to the specified category/tag
  11. $limit = array(
  12. 'cat_ids' => '',
  13. 'tag_ids' => '',
  14. 'post_ids' => '',
  15. );
  16.  
  17. // Get events, then classify into date array
  18. $event_results = $ai1ec_calendar_helper->get_events_relative_to(
  19. $timestamp, $events_per_page, 0, $limit );
  20. $dates = $ai1ec_calendar_helper->get_agenda_date_array( $event_results['events'] );
  21.  
  22.  
  23. if( ! $dates ) :
  24. ?>
  25. <p class="ai1ec-no-results">
  26. <?php _e( 'There are no upcoming events.', AI1EC_PLUGIN_NAME ); ?>
  27. </p>
  28. <?php else: ?>
  29. <ol>
  30. <?php foreach( $dates as $timestamp => $date_info ): ?>
  31.  
  32. <?php foreach( $date_info['events'] as $category ): ?>
  33. <?php foreach( $category as $event ): ?>
  34.  
  35. <li><!-- Review file agenda-widget.php --></li>
  36.  
  37. <?php endforeach; ?>
  38. <?php endforeach; ?>
  39.  
  40. <?php endforeach; ?>
  41. </ol>
  42. <?php
  43. endif;
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement