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 ): ?>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span>Custom field from $post: <?php the_field('author'); ?></span>
<?php endforeach; ?>
<?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?
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users