Advertisement
Apina

EE4 date loop

Jun 8th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. // Loop through dates in EE4
  3. // This is NOT supported by Event Espresso. It is just an EXAMPLE. It is also probably not that well optimized!
  4. // Use as a basis for your own code and at your own risk!
  5. ?>
  6.  
  7.  
  8. <?php
  9. //get the dates in an array we can loop through
  10. $the_dates = array(
  11. 'June 2015',
  12. 'July 2015',
  13. 'August 2015'
  14. );
  15. ?>
  16.  
  17. <?php
  18. foreach ( $the_dates as $date ) {
  19. ?>
  20. <ul class="events">
  21. <?php
  22. $atts = array(
  23. 'title' => NULL,
  24. 'limit' => 100,
  25. 'css_class' => NULL,
  26. 'show_expired' => FALSE,
  27. 'month' => $date,
  28. 'category_slug' => NULL,
  29. 'order_by' => 'start_date',
  30. 'sort' => 'ASC',
  31. 'limit' => 3
  32. );
  33. // run the query
  34. global $wp_query;
  35. $wp_query = new EE_Event_List_Query( $atts );
  36. if (have_posts()) : while (have_posts()) : the_post();
  37. ?>
  38. <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  39. <?php do_action( 'AHEE_event_details_after_the_event_title', $post ); ?>
  40. </li>
  41. <?php
  42. endwhile;
  43. else:
  44. ?>
  45. <li>No Upcoming Events</li>
  46. <?php
  47. endif;
  48. // now reset the query and postdata
  49. wp_reset_query();
  50. wp_reset_postdata();
  51. ?>
  52. </ul>
  53.  
  54. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement