We are going to reduce duplication of code on pages and sections Upcoming Events
CREATE NEW FOLDER theme/template-parts/event.php
And that content-event.php file can be called to a page like this
while($homepageEvents->have_posts()){
$homepageEvents->the_post();
//Import template-parts/event.php
get_template_part('template-parts/content-event');
OR below better that comma is like a dash
get_template_part('template-parts/content', 'event');
} wp_reset_postdata();
get_template_part can also be written like this for expanded capabilities
get_template_part('template-parts/event', get_post_type());