Skip to content

Instantly share code, notes, and snippets.

@g-maclean
Created August 28, 2025 14:38
Show Gist options
  • Save g-maclean/e61738c16c69f18fda028d4db4ddc6cd to your computer and use it in GitHub Desktop.
Save g-maclean/e61738c16c69f18fda028d4db4ddc6cd to your computer and use it in GitHub Desktop.
PropertyHive - custom shortcode for outputting a custom bulleted list
add_shortcode('property_details_list', 'custom_property_details_list_shortcode');
function custom_property_details_list_shortcode($atts) {
global $post;
$property = new PH_Property($post->ID);
$details = array(
'Price' => $property->price,
'Property Type' => $property->get_property_type(),
'Bedrooms' => $property->bedrooms,
'Bathrooms' => $property->bathrooms,
'Reception Rooms' => $property->receptions,
'Floor Area' => $property->build_area ? $property->build_area . ' sqm' : '',
'Plot Area' => $property->plot_area ? $property->plot_area . ' sqm' : '',
'Tenure' => get_post_meta($post->ID, '_tenure', true),
'EPC Rating' => get_post_meta($post->ID, '_ber_rating', true),
'Letting Term' => get_post_meta($post->ID, '_letting_term', true),
);
ob_start();
echo '<ul class="property-details-list">';
foreach ($details as $label => $value) {
if (!empty($value)) {
echo '<li><strong>' . esc_html($label) . ':</strong> ' . esc_html($value) . '</li>';
}
}
echo '</ul>';
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment