Skip to content

Instantly share code, notes, and snippets.

@g-maclean
Created November 20, 2025 13:34
Show Gist options
  • Select an option

  • Save g-maclean/0fc1a9a7fbd8719b1340adef5f1243e5 to your computer and use it in GitHub Desktop.

Select an option

Save g-maclean/0fc1a9a7fbd8719b1340adef5f1243e5 to your computer and use it in GitHub Desktop.
Property Hive - Reapit - use extra address field for location
add_action( "propertyhive_property_imported_reapit_json", 'assign_location_from_extra_field', 10, 2 );
function assign_location_from_extra_field( $post_id, $property ) {
$location_set = false;
if ( isset( $property['address']['line3'] ) && trim( $property['address']['line3'] ) != '' ) {
$reapit_location = trim( $property['address']['line3'] );
$term = term_exists( $reapit_location, 'location' );
if ( $term !== 0 && $term !== null && isset( $term['term_id'] ) ) {
$location_set = true;
wp_set_object_terms( $post_id, array( (int)$term['term_id'] ), 'location' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment