<?php // Get RSS Feed(s) include_once( ABSPATH . WPINC . '/feed.php' ); // Get a SimplePie feed object from the specified feed source. $rss = fetch_feed( 'https://your_url_rss_feed' ); if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly // Figure out how many total items there are, but limit it to 5. $maxitems = $rss->get_item_quantity( 3 ); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items( 0, $maxitems ); endif; ?> <div class="newsletter_grid"> <?php if ( $maxitems == 0 ) : ?> <div><?php _e( 'No items', 'my-text-domain' ); ?></div> <?php else : ?> <?php // Loop through each feed item and display each item as a hyperlink. ?> <?php foreach ( $rss_items as $item ) : ?> <div class="newsletter_item"> <div class="newsletter_title"> <a target="_blank" href="<?php echo esc_url( $item->get_permalink() ); ?>" title="<?php printf( __( 'Posted %s', 'my-text-domain' ), $item->get_date('j F Y | g:i a') ); ?>"> <?php $title = $item->get_title(); $limited_title = substr($title, 0, 70);; ?> <h3><?php echo $limited_title; ?></h3> </a> </div> <div class="newsletter_excerpt"> <?php $description = $item->get_description(); // Get the description $limited_description = wp_trim_words( $description, 20 ); // Limit to 20 words echo $limited_description; ?> </div> <div class="newsletter_date"> <?php //echo esc_html( $item->get_date('j F Y') ); echo date_i18n( 'j. F Y', false, false); ?> </div> <a target="_blank" class="newsletter_link" href="<?php echo esc_url( $item->get_permalink() ); ?>">Weiterlesen</a> </div> <?php endforeach; ?> <?php endif; ?> </div>