Okay, I got this and all things are good but it will not display the posts because we have to add them in every post, is it possible that the same name or slug will take the tags posts.
/** CITIES **/
/*
* Add Custom Taxonomies
*/
function cities_custom_taxonomies() {
$taxonomies = array(
// Director
array(
'name' => 'city', // here the name of the taxonomy
'single' => 'City', // here the single taxonomy name to show in the backend
'plural' => 'Cities', // here the plural taxonomy name to show in the backend
'cpt' => 'post' ), // which Custom Post Type to associate the taxonomy
);
foreach ($taxonomies as $taxonomy) {
$name = $taxonomy['name'];
$single = $taxonomy['single'];
$plural = $taxonomy['plural'];
$cpt = $taxonomy['cpt'];
$labels = array(
'name' => _x( $plural, 'taxonomy general name' ),
'singular_name' => _x( $single, 'taxonomy singular name' ),
'search_items' => __( 'Search '. $plural ),
'all_items' => __( 'All '. $plural ),
'parent_item' => __( 'Parent '. $single ),
'parent_item_colon' => __( 'Parent '. $single.':' ),
'edit_item' => __( 'Edit '. $single ),
'update_item' => __( 'Update '. $single ),
'add_new_item' => __( 'Add New '. $single ),
'new_item_name' => __( 'New Name '. $single ),
'menu_name' => __( $plural )
);
$args = array(
'labels' => $labels,
'hierarchical' => true, // false: as Tags, true: as Category
'show_ui' => true,
'show_admin_column' => true
);
register_taxonomy( $name, $cpt, $args );
} //foreach
}
add_action( 'init', 'cities_custom_taxonomies', 0 );