我在 wordpress 中有一个房地产网站。
在每个列出的属性下都显示了一个相应的代理。一切正常,但问题是我希望也显示该代理的特色图像。
这是在每个属性下显示代理的代码
<?php
//// CHECKS TO SEE IF WE HAVE ANY GENTS ASSIGNED TO THIS PROPERTY
if(get_post_meta(get_the_ID(), 'agents', true) != '' || ddp('public_submissions') == 'on') :
?>
<div id="property-agents">
<h2><?php _e('Contact Agent', 'btoa'); ?></h2>
<ul class="list-agents">
<?php
//// LETS LOOP OUR AGENTS
$agents = get_post_meta(get_the_ID(), 'agents', true);
//// IF WE HAVE AN ARRAY
if(is_array($agents)) :
foreach($agents as $agent) :
$this_agent = '';
//// IF IT'S A POST TYPE
if($this_agent = get_post($agent)) {
if($this_agent->post_type == 'agent') {
$name = $this_agent->post_title;
$position = get_post_meta($this_agent->ID, 'position', true);
$email = get_post_meta($this_agent->ID, 'email', true);
$phone = get_post_meta($this_agent->ID, 'phone', true);
} else { $this_agent = 'user'; }
} else { $this_agent = 'user'; }
if($this_agent == '' || $this_agent == 'user') {
if($this_agent = get_user_by('id', $agent)) {
$name = $this_agent->display_name;
$position = esc_attr( get_the_author_meta( 'position', $this_agent->ID ) );
$email = $this_agent->user_email;
$phone = get_the_author_meta( 'phone', $this_agent->ID );
}
}
//// IF WE HAVE GOTTEN THE USERS NAME
if($name) :
?>
<li>
<div class="two-fifths">
<h4><?php echo $name; ?></h4>
<h5><?php echo $position; ?></h5>
</div>
<!-- /.two-fifths/ -->
<div class="three-fifths last">
<?php if($email != '') : ?><div class="three-fifths"><strong><?php _e('Email', 'btoa'); ?></strong><a href="mailto:<?php echo $email; ?>" title="Email John"><?php echo $email; ?></a></div><?php endif; ?>
<?php if($phone != '') : ?><div class="two-fifths last"><strong><?php _e('Phone', 'btoa'); ?></strong><?php echo $phone; ?></div><?php endif; ?>
</div>
<!-- /.three-fifths/ -->
</li>
<?php endif; endforeach; endif; ?>
</ul>
</div>
<!-- /#property-agents/ -->
这是获取特色图片的代码
function ddTimthumb($img = NULL, $width = NULL, $height = NULL) {
//// IF AN imAGE HAS BEEN PROVIDED
if($img != NULL) {
$image = vt_resize('', $img, $width, $height, true );
//// IF ITS NOT AN ERROR
if(is_array($image)) { return $image['url']; } else { return ''; }
} else { return ''; }
}
function getFeaturedImage($post_id = NULL) {
if($post_id != NULL) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'single-post-thumbnail' );
return $image;
}
}