Created
November 19, 2024 16:12
-
-
Save g-maclean/c54bc1a1f810c892e409ca0a3329a2b2 to your computer and use it in GitHub Desktop.
PropertyHive - shortcode for displaying room counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_shortcode("room_counts", "output_room_counts"); | |
| function output_room_counts(){ | |
| global $property; | |
| $bedrooms = $property->bedrooms; | |
| $bathrooms = $property->bathrooms; | |
| $reception_rooms = $property->reception_rooms; | |
| $rooms= []; | |
| if ( !empty($bedrooms) ) { | |
| $rooms[] = $bedrooms . ' Bedroom' . ( ( $bedrooms != 1 ) ? 's' : '' ); | |
| } | |
| if ( !empty($bathrooms) ) { | |
| $rooms[] = $bathrooms . ' Bathroom' . ( ( $bathrooms != 1 ) ? 's' : '' ); | |
| } | |
| if ( !empty($reception_rooms) ) { | |
| $rooms[] = $reception_rooms . ' Reception' . ( ( $reception_rooms != 1 ) ? 's' : '' ); | |
| } | |
| return "<div class='room_counts'>" . implode(', ', $rooms) . "</div>"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment