Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Retrive the city of suite */
- function retive_city_of_suite($suite_id, $return_array_type=false) {
- $temp_property_id = get_post_meta($suite_id, 'id_property_under', TRUE);
- global $wpdb;
- $temp_city = $wpdb->get_var("SELECT "
- . " {$wpdb->prefix}terms.term_id FROM {$wpdb->prefix}term_relationships "
- . " INNER JOIN {$wpdb->prefix}posts ON {$wpdb->prefix}posts.ID = {$wpdb->prefix}term_relationships.object_id"
- . " INNER JOIN {$wpdb->prefix}term_taxonomy ON {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id"
- . " INNER JOIN {$wpdb->prefix}terms ON {$wpdb->prefix}term_taxonomy.term_id = {$wpdb->prefix}terms.term_id WHERE {$wpdb->prefix}posts.ID = $temp_property_id"
- . " AND {$wpdb->prefix}posts.post_status = 'publish'");
- $parent = get_term_by('id', $temp_city, 'city');
- while ($parent->parent != 0) {
- $parent = get_term_by('id', $parent->parent, 'city');
- }
- if($return_array_type){
- return array('name'=>$parent->name,'term_id' =>$parent->term_id, 'slug'=>$parent->slug);
- }else{
- return $parent->name;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement