<?php
$today = date('Ymd');
$pastEvents = new WP_Query(array(
'paged' => get_query_var('paged', 1),
//'posts_per_page' => -1,//-1 will show all items
'posts_per_page' => 1,
//Get the new post_type here
//This has been registered on wp-content/mu-plugins new folder
'post_type' => 'event',
//Default 'post_date" is.
//'orderby' => 'post_date',
//'orderby' => 'title',
//'orderby' => 'rand',
'meta_key' => 'event_date',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'event_date',
'compare' => '<',
'value' => $today,
'type' => 'numeric'
)
)
));
while($pastEvents->have_posts()) {
$pastEvents->the_post(); ?>
<div class="event-summary">
<a class="event-summary__date t-center" href="<?php the_permalink(); ?>">
<span class="event-summary__month">
<?php $eventDate = new DateTime(get_field('event_date'));
echo $eventDate->format('M')
?>
</span>
<span class="event-summary__day">
<?php
echo $eventDate->format('d')
?>
</span>
</a>
<div class="event-summary__content">
<h5 class="event-summary__title headline headline--tiny"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
<p><?php echo wp_trim_words(get_the_content(), 10) ?> <a href="<?php the_permalink(); ?>" class="nu gray">Read more</a></p>
</div>
</div>
<?php }
//Adding Pagination Here
//This will not work cause it wants to paginate core elements
//echo paginate_links();
echo paginate_links(array(
'total' => $pastEvents->max_num_pages
));
?>