Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Upcoming Events & Events Underday
- $now = date('Y-m-d H:i:s');
- $args = array(
- 'post_type' => 'events_post_tyoe',
- 'posts_per_page' => -1,
- 'meta_query' => array(
- 'relation' => 'OR',
- 'date_upcoming_clause' => array(
- 'key' => 'event_start_date',
- 'compare' => '>=',
- 'value' => $now,
- 'type' => 'DATETIME'
- ),
- array(
- 'relation' => 'AND',
- 'date_started_clause' => array(
- 'key' => 'event_start_date',
- 'compare' => '<=',
- 'value' => $now,
- 'type' => 'DATETIME'
- ),
- 'date_end_clause' => array(
- 'key' => 'event_end_date',
- 'compare' => '>=',
- 'value' => $now,
- 'type' => 'DATETIME'
- ),
- ),
- ),
- 'orderby' => array(
- 'date_started_clause' => 'ASC',
- 'date_end_clause' => 'ASC',
- 'date_upcoming_clause' => 'ASC',
- ),
- );
- $the_query = new WP_Query($args);
- ?>
- <h3>Upcoming Events</h3>
- <?php while ( have_posts() ) : the_post(); ?>
- <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
- <a class="list-article" href="<?php the_permalink(); ?>">
- <header class="entry-header">
- <div class="entry-meta">
- <span class="posted-on"><time class="entry-date published updated"><?php the_field('event_start_date'); ?></time></span>
- </div>
- <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
- </header>
- <?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>
- <div class="entry-content">
- <?php the_excerpt(); ?>
- </div>
- </a>
- </article>
- <?php endwhile; ?>
- <?php else : ?>
- <p>No events.</p>
- <?php endif; ?>
- <?php
- // Upcoming Events
- $today = date('Ymd');
- $args = array (
- 'post_type' => 'post',
- 'meta_query' => array(
- array(
- 'key' => 'start_date',
- 'compare' => '>',
- 'value' => $today,
- )
- ),
- );
- $posts = get_posts($args);
- ?>
- <h2>Past Events</h2>
- <?php while ( have_posts() ) : the_post(); ?>
- <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
- <a class="list-article" href="<?php the_permalink(); ?>">
- <header class="entry-header">
- <div class="entry-meta">
- <span class="posted-on"><time class="entry-date published updated"><?php the_field('event_start_date'); ?></time></span>
- </div>
- <?php the_title( sprintf( '<h2 class="entry-title">', esc_url( get_permalink() ) ), '</h2>' ); ?>
- </header>
- <?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>
- <div class="entry-content">
- <?php the_excerpt(); ?>
- <?php
- wp_link_pages( array(
- 'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
- 'after' => '</div>',
- ) );
- ?>
- </div>
- </a>
- </article>
- <?php endwhile; ?>
Add Comment
Please, Sign In to add comment