Skip to content

Instantly share code, notes, and snippets.

@cphilippsen
Created April 8, 2012 15:48
Show Gist options
  • Save cphilippsen/2338078 to your computer and use it in GitHub Desktop.
Save cphilippsen/2338078 to your computer and use it in GitHub Desktop.
ACF Relationship get related posts fields content
<?php if(get_field('relationship')): ?>
<h2>Related posts</h2>
<ul id="portfolio-grid">
<?php foreach(get_field('relationship') as $related): ?>
<li>
<a href="<?php echo get_permalink($related->ID); ?>" title="<?php echo get_the_title($related->ID) ?>">
<img src="<?php the_field('image_src', $related->ID); ?>" alt="" /> <span class="caption"><?php the_field('image_caption', $related->ID); ?></span>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment