我正在为分类代理使用高级自定义字段。我想做的是让那些拥有there信息的代理进入分类,这样他们就有了there图像、个人简历、电话、手机和电子邮件,然后当我们创建一个新属性并将其设置为Jane Doe代理时。然后它会显示她在列表中的信息,如她的图像、电话、电子邮件分机。但如果我选择其他代理,它会显示那里的信息。下面是我想出的代码,但无论选择谁,这都将始终显示agent\\u 16。
如何设置它以显示所选的代理信息?
<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>