Last active
June 11, 2026 02:36
-
-
Save g-maclean/a503251b387aa16158d6918ad1727bf5 to your computer and use it in GitHub Desktop.
Property Hive - Reapit - Alternate URL with ref
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_action( 'propertyhive_property_imported_reapit_foundations_json', 'reapit_alt_url', 10, 2 ); | |
| function reapit_alt_url( $post_id, $property ) { | |
| // Used for the post title | |
| $full_address_parts = array_filter( array( | |
| $property['address']['line1'] ?? '', | |
| $property['address']['line2'] ?? '', | |
| $property['address']['line3'] ?? '', | |
| $property['address']['line4'] ?? '', | |
| $property['address']['postcode'] ?? '', | |
| ) ); | |
| // Used for the URL slug | |
| $slug_parts = array_filter( array( | |
| $property['address']['line4'] ?? '', | |
| $property['address']['line3'] ?? '', | |
| $property['address']['line2'] ?? '', | |
| $property['id'] ?? '', | |
| ) ); | |
| $post_title = implode( ', ', $full_address_parts ); | |
| $post_slug = implode( ', ', $slug_parts ); | |
| $post_data = array( | |
| 'ID' => $post_id, | |
| 'post_title' => wp_strip_all_tags( $post_title ), | |
| 'post_name' => sanitize_title( $post_slug ), | |
| 'post_excerpt' => $property['description'] ?? '', | |
| 'post_status' => 'publish', | |
| ); | |
| wp_update_post( $post_data, true ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment