Skip to content

Instantly share code, notes, and snippets.

@propertyhive
propertyhive / gist:1ff79d6d48e2da4a46adca51f8771942
Created April 1, 2025 12:12
Ignore address fields when radius is being searched
add_filter('propertyhive_radial_search_ignore_address', 'ignore_address');
function ignore_address($ignore)
{
return true;
}
add_action( "propertyhive_sturents_property_imported", 'set_status_on_sturents', 10, 2 );
function set_status_on_sturents( $post_id, $property )
{
wp_suspend_cache_invalidation( true );
wp_defer_term_counting( true );
wp_defer_comment_counting( true );
wp_set_post_terms( $post_id, 5, 'availability' ); // Change 5 accordingly to new 'For Sale' status
wp_suspend_cache_invalidation( false );
@propertyhive
propertyhive / gist:5ca13c7fddbab05989509cf7b2d1b830
Created March 27, 2025 13:42
Correct Rex commercial lettings availability
add_action( "propertyhive_property_imported_rex_json", 'correct_commercial_availabilities', 10, 2 );
function correct_commercial_availabilities($post_id, $property)
{
$department = get_post_meta( $post_id, '_department', TRUE );
$to_rent = get_post_meta( $post_id, '_to_rent', TRUE );
if ( $department == 'commercial' && $to_rent == 'yes' )
{
wp_suspend_cache_invalidation( true );
wp_defer_term_counting( true );
@propertyhive
propertyhive / gist:6af77083bbc216ea14fa225ebacd5f06
Created March 27, 2025 12:00
Add imported property ID to enquiries
add_filter( 'propertyhive_property_enquiry_property_output', 'add_rex_property_id_to_enquiries', 10, 2 );
function add_rex_property_id_to_enquiries( $output, $property_id )
{
$property = new PH_Property($property_id);
$output = $property->get_formatted_full_address() . "\n" .
$property->get_formatted_price() . "\n" .
get_permalink( (int)$property_id ) . "\n" .
'Property ID: ' . $property->imported_id;
add_action( "propertyhive_property_imported_gnomen_xml", 'import_new_home_custom_field', 10, 2 );
function import_new_home_custom_field($post_id, $property)
{
if ( isset($property->property_no) && strtolower((string)$property->new_home, 'preown') !== false )
{
update_post_meta( $post_id, '_new_home', 'Pre-owned Home' );
}
else
{
update_post_meta( $post_id, '_new_home', 'New Home' );
add_action( "propertyhive_wpresidence_property_synced", 'sync_material_info_stuff_to_wpr', 10, 3 );
function sync_material_info_stuff_to_wpr( $ph_post_id, $wpr_post_id, $synced )
{
if ( $synced === true )
{
$property = new PH_Property($ph_post_id);
// Utilities and Accessibility
$utility_types = array(
'electricity',
add_action( "houzez_property_feed_property_imported_resales_online_api", 'import_orientation', 10, 4 );
function import_orientation( $post_id, $property, $import_id, $instance_id )
{
if (isset($property['PropertyFeatures']['Category'])) {
foreach ($property['PropertyFeatures']['Category'] as $feature) {
if (isset($feature['Type']) && $feature['Type'] === 'Orientation') {
if (!empty($feature['Value'][0])) {
update_post_meta($post_id, 'fave_orientation', $feature['Value'][0]); // assuming the meta key 'fave_orientation' here. Would need login access to confirm this if it doesn't work
}
break;
add_action( "propertyhive_property_imported_vebra_api_xml", 'import_energy_stuff', 10, 2 );
function import_energy_stuff( $post_id, $property )
{
if (
isset($property->hip->energy_performance->energy_efficiency->current) &&
(string)$property->hip->energy_performance->energy_efficiency->current != '' &&
(string)$property->hip->energy_performance->energy_efficiency->current != '0'
)
{
update_post_meta( $post_id, '_energy_efficiency_current', (string)$property->hip->energy_performance->energy_efficiency->current );
add_action( "houzez_property_feed_property_imported_resales_online_api", 'hpf_custom_functionality', 10, 4 );
function hpf_custom_functionality( $post_id, $property, $import_id, $instance_id )
{
if (
isset($property['PropertyFeatures']['Category'][0]['Value']) &&
is_array($property['PropertyFeatures']['Category'][0]['Value']) &&
in_array('New Development', $property['PropertyFeatures']['Category'][0]['Value'])
)
{
// Yes it exists. Do something here. Set a postmeta or similar using update_post_meta()
add_action('parse_query', 'set_default_location_search_criteria');
function set_default_location_search_criteria()
{
if ( !is_admin() && !isset($_GET['location']) )
{
$_GET['location'] = X; // Change X accordingly
$_REQUEST['location'] = X; // Change X accordingly
}
}