I bought I real estate theme, I need a child category for Community custom taxonomy so i set the Hierarchical to True. But when I tried displaying it in my page the Community comes first before the sub community. This is what it displays:
"Business Bay, Business Tower, Dubai, UAE"
instead of
"Business Tower, Business Bay, Dubai, UAE"
Business towers is the child, Business bay is the parent. It should be child first before the parent right?
can you please help me.
Here is the code:
$communitylabels = array(
'name' => __( 'Community', 'contempo' ),
'singular_name' => __( 'Community', 'contempo' ),
'search_items' => __( 'Search Communities', 'contempo' ),
'popular_items' => __( 'Popular Communities', 'contempo' ),
'all_items' => __( 'All Communities', 'contempo' ),
'parent_item' => __( 'Parent', 'contempo' ),
'parent_item_colon' => __( 'Parent', 'contempo' ),
'edit_item' => __( 'Edit Community', 'contempo' ),
'update_item' => __( 'Update Community', 'contempo' ),
'add_new_item' => __( 'Add New Community', 'contempo' ),
'new_item_name' => __( 'New Community', 'contempo' ),
'separate_items_with_commas' => __( 'Separate Communities with commas', 'contempo' ),
'add_or_remove_items' => __( 'Add or remove Communities', 'contempo' ),
'choose_from_most_used' => __( 'Choose from the most used Communities', 'contempo' )
);
register_taxonomy( 'community', 'listings', array(
'hierarchical' => true,
'labels' => $communitylabels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'community' ),
));
}
if ( ! function_exists( 'community' ) ) {
function community() {
global $post;
global $wp_query;
$terms_as_text = strip_tags( get_the_term_list( $wp_query->post->ID, 'community', '', ', ', '' ) );
echo esc_html($terms_as_text);
}
}
Here is the code when i call the custom taxonomy:
// Title
case 'listing_title' :
echo '<h2 class="marT5 marB0">';
ct_listing_title();
echo '</h2>';
break;
// location
case 'listing_city_state_zip' :
echo '<p class="location marB0">';
community();
echo ', ';
city();
echo '';
country();
echo '</p>';