|
add_action('init', 'make_registered_flat_taxonomies_hierarchical'); |
|
|
|
function make_registered_flat_taxonomies_hierarchical() { |
|
|
|
// Maintain the built-in rewrite functionality of WordPress tags |
|
|
|
global $wp_rewrite; |
|
|
|
$rewrite = array( |
|
'hierarchical' => false, // Maintains tag permalink structure |
|
'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag', |
|
'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(), |
|
'ep_mask' => EP_TAGS, |
|
); |
|
|
|
// Redefine tag labels (or leave them the same) |
|
|
|
$labels = array( |
|
'name' => _x( 'Tags', 'Taxonomy General Name' ), |
|
'singular_name' => _x( 'Tag', 'Taxonomy Singular Name' ), |
|
'menu_name' => __( 'Tags' ), |
|
'all_items' => __( 'All Tags' ), |
|
'parent_item' => __( 'Parent Tag' ), |
|
'parent_item_colon' => __( 'Parent Tag:' ), |
|
'new_item_name' => __( 'New Tag Name' ), |
|
'add_new_item' => __( 'Add New Tag' ), |
|
'edit_item' => __( 'Edit Tag' ), |
|
'update_item' => __( 'Update Tag' ), |
|
'view_item' => __( 'View Tag' ), |
|
'separate_items_with_commas' => __( 'Separate tags with commas' ), |
|
'add_or_remove_items' => __( 'Add or remove tags' ), |
|
'choose_from_most_used' => __( 'Choose from the most used' ), |
|
'popular_items' => __( 'Popular Tags' ), |
|
'search_items' => __( 'Search Tags' ), |
|
'not_found' => __( 'Not Found' ), |
|
); |
|
|
|
// Override structure of built-in WordPress tags |
|
|
|
register_taxonomy( 'post_tag', 'post', array( |
|
'hierarchical' => true, // Was false, now set to true |
|
'query_var' => 'tag', |
|
'labels' => $labels, |
|
'rewrite' => $rewrite, |
|
'public' => true, |
|
'show_ui' => true, |
|
'show_admin_column' => true, |
|
'_builtin' => true, |
|
) ); |
|
|
|
} |