1. Docs
  2. Developer Guide
  3. Miscellaneous and Snippets
  4. Display Room Counts

Display Room Counts

The below will show rooms counts on the search results page:

add_action( 'propertyhive_after_search_results_loop_item_title', 'output_room_counts', 25 ); // 25 sets the priority. Go lower to move it up the order, and vice versa

function output_room_counts()
{
    global $property;
    
    $bedrooms = $property->bedrooms;
    $bathrooms = $property->bathrooms;
    $reception_rooms = $property->reception_rooms;
    
    // Output HTML below. Something like...
?>
<div class="rooms">
    
    <!-- BEDROOMS -->
    <?php if ( !empty($bedrooms) ) { ?><div class="room bedrooms"><?php echo $bedrooms . ' Bedroom' . ( ( $bedrooms != 1 ) ? 's' : '' ); ?></div><?php } ?>
    
    <!-- BATHROOMS -->
    <?php if ( !empty($bathrooms) ) { ?><div class="room bathrooms"><?php echo $bathrooms . ' Bathroom' . ( ( $bathrooms != 1 ) ? 's' : '' ); ?></div><?php } ?>
    
    <!-- RECEPTION ROOMS -->
    <?php if ( !empty($reception_rooms) ) { ?><div class="room reception-rooms"><?php echo $reception_rooms . ' Reception' . ( ( $reception_rooms != 1 ) ? 's' : '' ); ?></div><?php } ?>
    
</div>
<?php
}

If wanting to display on the full details page you can do the same but change the action from ‘propertyhive_after_search_results_loop_item_title‘ to one of the actions available on the full details page (i.e. propertyhive_single_property_summary).

Was this article helpful to you? Yes No