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">


$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 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
} } ?>

                     <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>

1 Answer 1


You will be able to get the list of custom taxonomy by following code :

//list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin)

$taxonomy     = 'genre';
$orderby      = 'name'; 
$show_count   = 0;      // 1 for yes, 0 for no
$pad_counts   = 0;      // 1 for yes, 0 for no
$hierarchical = 1;      // 1 for yes, 0 for no
$title        = '';

$args = array(
  'taxonomy'     => $taxonomy,
  'orderby'      => $orderby,
  'show_count'   => $show_count,
  'pad_counts'   => $pad_counts,
  'hierarchical' => $hierarchical,
  'title_li'     => $title

<?php wp_list_categories( $args ); ?>

Do check and let me know if you find it usefull

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.