I am new to support forum and need help with the following code:
At the end of my posts I’m intending to display x3 related_posts. Everything works Ok apart from the_excerpt. The except text displays wrong but links correctly to the post.
$posts = get_field('related_posts' );
if( $posts) {
echo '<h1>Further Reading</h1>';
echo '<ul class="Further Reading">';
foreach( $posts as $related_posts ): // Open foreach loop
echo '<li> <a href="' . get_the_permalink( $related_posts->ID ) . '">';
echo '<h3>' . get_the_title( $related_posts->ID ) . '</h3>';
echo '' . the_excerpt( $related_posts->ID ) . '
';
echo '</ul>'; // close list item
endforeach; //close foreach loop
echo '</ul>';
wp_reset_postdata(); //Restore original Post Data
}
Please help, many thanks