Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Created September 8, 2025 11:11
Show Gist options
  • Save propertyhive/0da348ddc592fc61c70a728f1e7cb132 to your computer and use it in GitHub Desktop.
Save propertyhive/0da348ddc592fc61c70a728f1e7cb132 to your computer and use it in GitHub Desktop.
/* Get parking */
add_action( "propertyhive_property_imported_jupix_xml", 'assign_parking_taxonomy', 10, 2 );
function assign_parking_taxonomy($post_id, $property)
{
wp_suspend_cache_invalidation( true );
wp_defer_term_counting( true );
wp_defer_comment_counting( true );
$parking_types = array();
if ( isset($property->parking) && isset($property->parking->type) )
{
if (isset($property->parking) && isset($property->parking->type)) {
foreach ($property->parking->type as $type) {
if (trim((string)$type) != '') {
$parking_types[] = sanitize_text_field((string)$type);
}
}
}
}
if ( !empty($parking_types) )
{
wp_set_object_terms( $post_id, $parking_types, 'parking' ); // removed 'TRUE'
}
else
{
wp_delete_object_term_relationships( $post_id, 'parking' );
}
wp_suspend_cache_invalidation( false );
wp_defer_term_counting( false );
wp_defer_comment_counting( false );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment