Wordpress getFeaturedImage -
i have real-estate website in wordpress.
under each listed property displayed corresponding agent. works fine, problem want agent's featured image displayed well.
here code displaying agent under each property
<?php //// checks see if have gents assigned 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 have array if(is_array($agents)) : foreach($agents $agent) : $this_agent = ''; //// if it's 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 have gotten 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/ -->
and code gettin featured image
function ddtimthumb($img = null, $width = null, $height = null) { //// if image has been provided if($img != null) { $image = vt_resize('', $img, $width, $height, true ); //// if not 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; } }
you can use function featured image.
<?php echo getfeaturedimage($this_agent->id); ?>
Comments
Post a Comment