WP_Query() Class, Fetch New Events

<div class="full-width-split__inner">
<h2 class="headline headline--small-plus t-center">Upcoming Events</h2>

<?php

  $homepageEvents = new WP_Query(array(
    'posts_per_page' => 2,
    //Get the new post_type here
    //This has been registered on wp-content/mu-plugins new folder
    'post_type' => 'event'
  ));
  //$Object = new Class()

  while($homepageEvents->have_posts()){
    $homepageEvents->the_post(); ?>

    <div class="event-summary">
      <a class="event-summary__date t-center" href="<?php the_permalink(); ?>">
        <span class="event-summary__month"><?php the_time('M'); ?></span>
        <span class="event-summary__day"><?php the_time('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 } wp_reset_postdata();

?>

<p class="t-center no-margin"><a href="<?php echo site_url('/events'); ?>" class="btn btn--blue">View All Events</a></p>
</div>

REMEMBER TO GO TO ADMIN PERMALINKS AND SAVE PERMALINKS IN ORDER TO the_permalink() TO START WORKING!!!
Scroll to Top