Last active
February 23, 2026 19:36
-
-
Save propertyhive/f3c6c2e8ee0cd5fb47356afb3108d4fa to your computer and use it in GitHub Desktop.
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( "houzez_property_feed_property_imported_resales_online", 'custom_features_structure', 10, 4 ); | |
| function custom_features_structure($post_id, $property, $import_id, $instance_id) | |
| { | |
| $feature_term_ids = array(); | |
| if ( isset($property->characteristics->category) ) | |
| { | |
| foreach ( $property->characteristics->category as $category ) | |
| { | |
| if ( | |
| isset($category->name->uk) && | |
| (string)$category->name->uk == 'Features' && | |
| isset($category->value) | |
| ) | |
| { | |
| foreach ( $category->value as $feature ) | |
| { | |
| $new_feature = trim((string)$feature->uk); | |
| $term = term_exists( $new_feature, 'property_feature'); | |
| if ( $term !== 0 && $term !== null && isset($term['term_id']) ) | |
| { | |
| $feature_term_ids[] = (int)$term['term_id']; | |
| } | |
| elseif ( apply_filters( 'houzez_property_feed_auto_create_new_features', true ) === true ) | |
| { | |
| $term = wp_insert_term( $new_feature, 'property_feature' ); | |
| if ( is_array($term) && isset($term['term_id']) ) | |
| { | |
| $feature_term_ids[] = (int)$term['term_id']; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| if ( !empty($feature_term_ids) ) | |
| { | |
| wp_set_object_terms( $post_id, $feature_term_ids, "property_feature" ); | |
| } | |
| else | |
| { | |
| wp_delete_object_term_relationships( $post_id, "property_feature" ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment