I am using Advanced Custom Fields for the taxonomy agent. What I am trying to do is have Agents that have there info put into the taxonomy so that they have there image, bio, phone, cell and email then when we create a new property and set it to say agent Jane Doe. Then it would show her info on that listing such as her image, phone, email ext. But if I would choose a different agent it would show there info. Below is the code that I have come up with but this will always show agent_16 no mater who is selected.
How can I set it so that it will show the agent info that is selected?
<div class="listing-agent">
<div class="small-12 medium-6 large-6 columns">
<?php
$image = get_field('agent_image_d', 'agent_16');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
<div class="small-12 medium-6 large-6 columns">
<?php // Get terms for post
$terms = get_the_terms( $post->ID , 'agent' );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
unset($term);
} } ?>
<div class="agent-title"><?php the_field( 'agent_title_d', 'agent_16' ); ?></div>
<div class="office-phone">Office: (555) 555-55555</div>
<div class="agent-cell"><?php the_field( 'agent_cell_d', 'agent_16' ); ?></div>
<div class="agent-fax"><?php the_field( 'agent_fax_d', 'agent_16' ); ?></div>
<div class="agent-email"><?php the_field( 'agent_email_d', 'agent_16' ); ?></div>
</div>