Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/f0fb3d4eb0a6b504ed42cf7d5192c6cd to your computer and use it in GitHub Desktop.
Save propertyhive/f0fb3d4eb0a6b504ed42cf7d5192c6cd to your computer and use it in GitHub Desktop.
Shortcode to output property owners
add_shortcode('property_address', 'property_owners');
function property_owners()
{
global $property;
if ( !isset($property->id) ) {
return;
}
ob_start();
$owner_contact_ids = get_post_meta(($property->id, '_owner_contact_id', TRUE);
if ( !empty($owner_contact_ids) )
{
foreach ( $owner_contact_ids as $owner_contact_id )
{
$contact = new PH_Contact($owner_contact_id);
echo '<p>';
echo 'Name: ' . get_the_title($owner_contact_id) . '<br>';
echo 'Tel: ' . $contact->telephone_number . '<br>';
echo 'Email: ' . $contact->email_address;
echo '</p>';
}
}
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment