2021-01-10 15:07:40

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

FilterMake Registered Flat taxonomies Hierarchical (example for Tags)

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,
	) );

}