how to assign cities to areas by id and not by name

Viewed 35

I am using houzez theme and trying to import areas with wp all import. To assign city to area i am using a code that they provide. But i need these code to search and retrieve data from an id (city_id) that i made with acf

the code that they suggest using is:

function link_houzez_city( $id, $xml, $is_update ) {

    // Retrieve 'parent_city' and use it to find that City.
    $term = get_term_by( "name", get_term_meta($id, "parent_city", true), "property_city" );

    // Retrieve the City's slug.
    $slug = $term->slug;
    
    // Generate the appropriate Option name.
    $option_name = '_houzez_property_area_' . $id;
    
    // Set the option to link this Neighborhood to its City.
    update_option($option_name, array("parent_city"=>$slug));

}
add_action( 'pmxi_saved_post', 'link_houzez_city', 10, 3 );
0 Answers
Related