Related Programs III Display On single-program.php page

            <?php
              $today = date('Ymd');
              $homepageEvents = new WP_Query(array(
                //'posts_per_page' => -1,//-1 will show all items
                'posts_per_page' => 2,
                //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'
                  ),
                  array(
                    'key' => 'related_programs',
                    'compare' => 'LIKE',
                    'value' => '"' .get_the_ID() . '"'
                  )
                )
              ));
              //$Object = new Class()
              
              if($homepageEvents->have_posts()){

                echo '<hr class="section-break">';
                echo '<h2 class="headline headline--medium">Upcoming ' . get_the_title() .' Events</h2>';
  
                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 $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 if (has_excerpt()) {
                                // the_excerpt(); outputs some html p tag that we don't want so we go for: echo get_the_excerpt();
                                //the_excerpt();
                                echo get_the_excerpt();
                              } else {
                                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();


              }//end if statement

            ?>
Scroll to Top