Hi,
Using GP elements, I am trying to display related posts (using ACF relationship field) below a single post.
In my element (before_footer), I’ve used a similar code as the one mentioned in ACF ressources (https://www.advancedcustomfields.com/resources/relationship/) :
<?php
$posts = get_field('relationship_field_name');
if( $posts ): ?>
<ul>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span>Custom field from $post: <?php the_field('author'); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
However, it doesn’t work, it displays data of my current post…
Should I add a wp_reset_postdata(); somewhere before ?
Thanks !