So I tried to re-use the code from content-espresso_events-thumbnail.php, but it shows the featured image from the current event page. Does anyone know how I should re-write the code?
Thanks
/* Show Related Events */
function ee_related_events() {
$posts = get_field('events');
if( $posts && is_singular( array( 'espresso_events') ) ): ?>
<div class="related-events">
<h3 class="event-venues-h3 ee-event-h3">Gerelateerde events</h3>
<ul>
<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
<?php
$img_ID = get_post_thumbnail_id( $post->ID );
$featured_img = wp_get_attachment_image_src( $img_ID, 'small' );
?>
<li>
<a href="<?php echo get_permalink( $p->ID ); ?>">
<div class="related-events-img" style="background:url(<?php echo $featured_img[0]; ?>)
The support post ‘Related Events ACF with featured image’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
If you would like help from the Event Espresso staff, then please purchase a support license right now so you can create a support topic in our premium support forums.