Home › Forums › General Issues › Querying relationship fields › Reply To: Querying relationship fields
Thanks for the screenshots.
The code you want to use will look something like this:
<div>
<a href="<?php the_permalink() ?>" title="<?php printf(__('%s','rys'), get_the_title()) ?>" rel="bookmark" ><?php the_title(); ?></a>
<em><?php the_field('publication_source'); ?></em>
<span><?php $date = get_field('publication_date'); echo date('F d, Y', datepicker_to_unix($date )); ?></span>
<?php
// 1. Get all the relationship values
$associations = get_field('associations');
// 2. Make sure a value exists
if( $associations ): ?>
<?php
// 3. loop through relatinoship values
foreach( $associations as $association): ?>
<?php // 4. Load the image field from the association ?>
<img src="<?php echo get_field('investment_logo', $association->ID); ?>" />
<?php endforeach; ?>
<?php endif; ?>
</div>
Please note this is an example and not the final Markup you will need.
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Plugin boilerplates can do some of the heavy lifting during initial development. We look at four options to speed up your plugin creation. https://t.co/ZtMsdBxAHw
— Advanced Custom Fields (@wp_acf) June 5, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.