if (has_excerpt()) the_excerpt() II


              <?php

                $homepagePosts = new WP_Query(array(
                  'posts_per_page' => 2
                ));

                //$Object = new Class()

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

                    <div class="event-summary">
                      <a class="event-summary__date event-summary__date--beige 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 if (has_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();

              ?>
Scroll to Top