Hi everyone, I’ve created some categories, for example “humans” and “monuments”. For “humans” I made relation custom field. When I choose post from humans, it displays my linked posts from category “monuments”. I used this code in single.php:
$posts = get_field('related_posts');
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 ?>
But it just looks like list in the current post. Now, I want to create link in this post that will be display result in “monument” category template. How is that possible to acheive?