Again very sorry for that! @jochen2016 @harv27
Would you mind checking with the following code?
add_action( 'wp_loaded', 'directorist_bulk_term_update' );
function directorist_bulk_term_update(){
if( get_option( 'directorist_bulk_term_update_v7' ) ) return;
$terms = [ ATBDP_CATEGORY, ATBDP_LOCATION ];
foreach( $terms as $term ) {
$term_data = get_terms([
'taxonomy' => $term,
'hide_empty' => false,
'orderby' => 'date',
'order' => 'DSCE',
]);
if( !empty( $term_data ) ) {
foreach( $term_data as $data ) {
$old_data = get_term_meta( $data->term_id, '_directory_type', true );
$results = is_array( $old_data ) ? $old_data[0] : $old_data;
if( !empty( $results ) ){
if( is_array( $old_data ) ){
foreach( $old_data as $single_data ){
if( ! is_numeric( $single_data ) ){
$term_with_directory_slug = get_term_by( 'slug', $single_data, 'atbdp_listing_types' );
$id = $term_with_directory_slug->term_id;
update_term_meta( $data->term_id, '_directory_type', [ $id ] );
}
}
}else{
if( ! is_numeric( $old_data ) ){
$term_with_directory_slug = get_term_by( 'slug', $old_data, 'atbdp_listing_types' );
$id = $term_with_directory_slug->term_id;
update_term_meta( $data->term_id, '_directory_type', [ $id ] );
}
}
}else{
update_term_meta( $data->term_id, '_directory_type', [ default_directory_type() ] );
}
}
}
}
update_option( 'directorist_bulk_term_update_v7', 1 );
}
Regards,