Output a list of similar properties to another property anywhere on the website using the shortcode:
[similar_properties]
By default this will output 2 properties in a random order and uses the content-property-featured.php template. A ‘similar’ property is classed as one that has a price 10% either side of the property in questions’ price, has the same number of bedrooms and is of the same department.
Usage in Templates
If wanting to show similar properties in one of the single property template:
echo do_shortcode("[similar_properties property_id=" . $property->id . "]");
Note: Requires the $property object to be declared as a global variable. Alternatively the below will do the same thing:
echo do_shortcode("[similar_properties property_id=" . get_the_ID() . "]");
Attributes
Attribute: per_page
Description: Determines the number of properties returned.
Default: 2
Example: [similar_properties per_page="6"]
Attribute: property_id
Description: The ID of the property in question
Default: (empty)
Example: [similar_properties property_id="413"]
Attribute: price_percentage_bounds
Description:The upper and lower price percentages when determining what properties are classed as ‘similar’. For example, if the property in question was £100,000 and this attribute was 10%, properties returned would be between £90,000 and £110,000. Pass as an empty string to not filter by price.
Default: 10
Example: [similar_properties price_percentage_bounds="15"]
Attribute: bedroom_bounds
Description:The upper and lower bedrooms number when determining what properties are classed as ‘similar’. If 0 only return properties with the same number of bedrooms. If a property had 2 bedrooms, passing this attribute as ‘1’ would include properties with 1 to 3 bedrooms. Pass as an empty string to not filter by bedrooms
Default: 0
Example: [similar_properties bedroom_bounds="1"]
Attribute: matching_address_field
Description: Allows you to specify only properties with the same address field should be returned.
Default: (empty)
Possible Values: address_two, address_three, address_four, location
Example: [similar_properties matching_address_field="address_three"]
Attribute: no_results_output
Description: The message output if no similar properties found
Default: (empty)
Example: [similar_properties no_results_output="No similar properties found"]