Guest User

Untitled

a guest
Apr 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. <?php
  2. // Upcoming Events & Events Underday
  3. $now = date('Y-m-d H:i:s');
  4.  
  5. $args = array(
  6. 'post_type' => 'events_post_tyoe',
  7. 'posts_per_page' => -1,
  8. 'meta_query' => array(
  9. 'relation' => 'OR',
  10. 'date_upcoming_clause' => array(
  11. 'key' => 'event_start_date',
  12. 'compare' => '>=',
  13. 'value' => $now,
  14. 'type' => 'DATETIME'
  15. ),
  16. array(
  17. 'relation' => 'AND',
  18. 'date_started_clause' => array(
  19. 'key' => 'event_start_date',
  20. 'compare' => '<=',
  21. 'value' => $now,
  22. 'type' => 'DATETIME'
  23. ),
  24. 'date_end_clause' => array(
  25. 'key' => 'event_end_date',
  26. 'compare' => '>=',
  27. 'value' => $now,
  28. 'type' => 'DATETIME'
  29. ),
  30. ),
  31. ),
  32. 'orderby' => array(
  33. 'date_started_clause' => 'ASC',
  34. 'date_end_clause' => 'ASC',
  35. 'date_upcoming_clause' => 'ASC',
  36. ),
  37. );
  38.  
  39. $the_query = new WP_Query($args);
  40.  
  41. ?>
  42. <h3>Upcoming Events</h3>
  43. <?php while ( have_posts() ) : the_post(); ?>
  44. <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
  45. <a class="list-article" href="<?php the_permalink(); ?>">
  46. <header class="entry-header">
  47. <div class="entry-meta">
  48. <span class="posted-on"><time class="entry-date published updated"><?php the_field('event_start_date'); ?></time></span>
  49. </div>
  50. <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
  51. </header>
  52. <?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>
  53. <div class="entry-content">
  54. <?php the_excerpt(); ?>
  55. </div>
  56. </a>
  57. </article>
  58. <?php endwhile; ?>
  59.  
  60. <?php else : ?>
  61. <p>No events.</p>
  62. <?php endif; ?>
  63.  
  64.  
  65.  
  66. <?php
  67. // Upcoming Events
  68. $today = date('Ymd');
  69.  
  70. $args = array (
  71. 'post_type' => 'post',
  72. 'meta_query' => array(
  73. array(
  74. 'key' => 'start_date',
  75. 'compare' => '>',
  76. 'value' => $today,
  77. )
  78. ),
  79. );
  80. $posts = get_posts($args);
  81. ?>
  82. <h2>Past Events</h2>
  83.  
  84. <?php while ( have_posts() ) : the_post(); ?>
  85. <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
  86. <a class="list-article" href="<?php the_permalink(); ?>">
  87. <header class="entry-header">
  88. <div class="entry-meta">
  89. <span class="posted-on"><time class="entry-date published updated"><?php the_field('event_start_date'); ?></time></span>
  90. </div>
  91. <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
  92. </header>
  93. <?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>
  94. <div class="entry-content">
  95. <?php the_excerpt(); ?>
  96. <?php
  97. wp_link_pages( array(
  98. 'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
  99. 'after' => '</div>',
  100. ) );
  101. ?>
  102. </div>
  103. </a>
  104. </article>
  105. <?php endwhile; ?>
Add Comment
Please, Sign In to add comment