The $property object
Introduction
The default templates output key information relating to a property record (price, bedrooms etc), however there may be scenarios where you want to access additional information about a property.
You should notice at the top of most templates we have the following:
global $property;
This gives us access to a 'property' object which contains all of the information about a property, as well as a number of helper methods.
We've outlined below all of these for use in your templates.
An example of accessing an individual property field would be:
echo $property->bedrooms;
As mentioned, we also have helper methods to, for example, output the price formatted with currency symbol etc. An example of using this would be:
echo $property->get_formatted_price();
Note that in the database we store meta fields as 'private' by prefixing them with an underscore (e.g. '_bedrooms').
Property Fields
Core information
id
- the WordPress post ID
department
- will be either ‘residential-sales’, ‘residential-lettings’, ‘commercial’, or a custom department if additional departments have been added under 'Property Hive > Settings > General'.
Address
reference_number
address_name_number
address_street
address_two
address_three
- labelled ‘Town/City’ in Property Hive
address_four
- labelled ‘County/State’ in Property Hive
address_postcode
address_country
- contains the ISO code for the country, e.g. GB, US, FR
location
- returns a comma delimited list of locations
latitude
longitude
The 'display address' uses the standard WordPress post title.
As such we don't a field for this and you can just use standard WordPress functions like get_the_title()
Record details
negotiator_id
negotiator_name
negotiator_telephone_number
negotiator_email_address
negotiator_photo
office_id
office_name
office_telephone_number
office_email_address
To output the office address see the helper method get_office_address()
Residential details
bedrooms
bathrooms
reception_rooms
property_type
council_tax_band
Residential sales details
currency
- returns the ISO code for currency, e.g. GBP, USD, EUR
price
- returns the price entered by the user
For outputting the price, we recommend you use the helper method get_formatted_price()
as that handles currencies, rent frequencies, POA and formatting.
price_actual
- returns the price converted to GBP. Only used for sorting and filtering.
poa
- returns ‘yes’ if POA ticked
price_qualifier
sale_by
tenure
leasehold_years_remaining
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
ground_rent
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
ground_rent_review_years
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
service_charge
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
service_charge_review_years
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
shared_ownership
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
shared_ownership_percentage
- only applicable when 'Tenure' is 'Leasehold' or 'Share of Freehold'
Residential lettings details
currency
- returns the ISO code for currency, e.g. GBP, USD, EUR
rent
- returns the price entered by the user
rent_frequency
- returns 'pppw', 'pw', 'pcm', 'pq' or 'pa'
For outputting the price, we recommend you use the helper method get_formatted_price()
as that handles currencies, rent frequencies, POA and formatting.
price_actual
- returns the rent converted to GBP and to PCM. Only used for sorting and filtering.
deposit
For outputting the deposit, we recommend you use the helper method get_formatted_deposit()
as that handles currencies and formatting.
available_date
For outputting the available date, we recommend you use the helper method get_available_date()
as that handles date formatting and shows 'Now' if the available date is in the past.
furnished
Commercial details
Marketing
on_market
- returns ‘yes’ if ‘On Market’ ticked
featured
- returns ‘yes’ if featured ticked. Also see the is_featured()
helper method.
availability
marketing_flag
- returns a comma delimited list of marketing flags
Descriptions
For the features you should use the helper method get_features()
.
For the summary description, we store this as the WordPress post excerpt. As a result you can use standard WordPress functions like get_the_excerpt() to obtain this.
For the full description you should use the helper method get_formatted_description()
.
Media
If you're storing media as 'Media Files' then all attachments can be obtained using helper methods.
If you're storing media as 'URLs' then these can be obtained using the following:
image_urls
floorplan_urls
brochure_urls
epc_urls
Helper Methods
General
get_formatted_full_address( $separator = ', ' )
- Outputs the full address, delimited with $separator
.
get_formatted_price()
- Returns the price in the correct currency, with formatting, including currency symbol and rent frequency. This will also output 'POA' when necessary
get_formatted_deposit()
- Returns the deposit in the correct currency, with formatting, including currency symbol
get_available_date()
- Returns the date available formatted correctly as per WordPress settings. If date has passed it will return ‘Now’.
get_formatted_description()
- Returns the full description, concatenating all of the rooms into HTML ready to be output.
get_features()
- Returns an array of the features entered.
get_office_address( $separator = ', ' )
- Outputs the full address, delimited with $separator
.
is_featured()
- Returns true or false
Media
get_main_photo_src( $size = 'thumbnail' )
- Returns the URL of the main property photo.
get_gallery_attachment_ids()
- Returns an array of photo attachment IDs
get_floorplan_attachment_ids()
- Returns an array of floorplan attachment IDs
get_brochure_attachment_ids()
- Returns an array of brochure attachment IDs
get_epc_attachment_ids()
- Returns an array of EPC attachment IDs
The above methods return WordPress attachment IDs. With these IDs you can use WordPress functions like wp_get_attachment_url() to get the URL of the attachment.
get_virtual_tours()
- Returns a multidimensional array of virtual tours with their label and URL
get_virtual_tour_urls()
- Returns an array of virtual tour URLs