Home Forums General Issues Querying relationship fields Reply To: Querying relationship fields

  • Hi @kikimarie1234

    Thanks for the screenshots.

    The code you want to use will look something like this:

    	<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>
    	// 1. Get all the relationship values
    	$associations = get_field('associations');
    	// 2. Make sure a value exists
    	if( $associations ): ?>
    		// 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; ?>

    Please note this is an example and not the final Markup you will need.