Taxonomy generator

Home » WordPress Generators » Taxonomy generator

This WordPress taxonomy generator is a user-friendly tool that simplifies the process of organizing your site’s content. Say goodbye to the tedious process of manually inputting labels and parameters. With intuitive interface, you’ll be up and running in no time. Try WPTurbo’s taxonomy generator today and streamline your WordPress development.

The name of the function that will be created.
Child Theme Support
Allow child themes to override this function.
Text domain translation file name.
The taxonomy key, must be unique. Lowercase. Less than 32 characters.
The singular name of the taxonomy.
The plural name of the taxonomy.
Hierarchical
Allow descendents?
Link your taxonomy to a built-in or custom post type key.
Disable For Public Query
Whether the taxonomy should be publicly queryable in admin interface or on front-end.
Don’t Show UI
Don’t generate the default UI for managing this taxonomy.
Don’t Show Admin Column
Don’t display taxonomy columns on associated post-types.
Don’t Show In Menu
Don’t make this taxonomy available for selection in navigation menus.
Don’t Show Tag Cloud
Don’t generate a tag cloud for this taxonomy.
Use Custom Query Variable
Taxonomy name is default variable name. Example: WP_Query( array( ‘taxonomy’ => ‘my_taxonomy‘ ) )
The custom query variable name.
Set Custom Capabilities
Set custom capabilities required to manage this taxonomy. Default: category capabilities.
The capability required to manage the taxonomy.
The capability required to edit the taxonomy.
The capability required to delete the taxonomy.
The capability required to assign the taxonomy.
Show In REST API
Whether to show the REST API Endpoint for this taxonomy.
The base slug that this taxonomy will use when accessed using the REST API. Default: Taxonomy Key.
The custom controller class that will be used for this taxonomy. Default: WP_REST_Terms_Controller.
The callback function that will be called to update the count.

This code snippet can be added in several places but we recommend to add it in a dedicated plugin (like a WordPress starter plugin) or in a must use plugin (which is a plugin that cannot be removed from the dashboard).

You can also add this snippet to your theme’s functions.php file but you’ll loose your customizations if you update it.

We recommend to use a Child theme to apply permanent features to your theme.

Overall, go for a dedicated plugin or a child theme to add snippets to your WordPress site.

                    function wpturbo_register_my_taxonomy(){
	$labels = array(
		'name' => _x( 'My Taxonomies', 'Taxonomy Name', 'wpturbo'),
		'singular_name' => _x( 'My Taxonomy', 'Taxonomy Singular Name', 'wpturbo'),
		'menu_name' => __( 'Taxonomies ', 'wpturbo' ),
		'all_items' => __( 'All Taxonomies ', 'wpturbo' ),
		'parent_item' => __( 'Parent Item ', 'wpturbo' ),
		'parent_item_colon' => __( 'Parent Item: ', 'wpturbo' ),
		'new_item_name' => __( 'New Taxonomy ', 'wpturbo' ),
		'add_new_item' => __( 'Add New ', 'wpturbo' ),
		'edit_item' => __( 'Edit Taxonomy ', 'wpturbo' ),
		'update_item' => __( 'Update ', 'wpturbo' ),
		'view_item' => __( 'View Taxonomy ', 'wpturbo' ),
		'add_or_remove_items' => __( 'Add Or Remove Items ', 'wpturbo' ),
		'choose_from_most_used' => __( 'Choose From Most Used ', 'wpturbo' ),
		'popular_items' => __( 'Popular Items ', 'wpturbo' ),
		'search_items' => __( 'Search Items ', 'wpturbo' ),
		'not_found' => __( 'Not Found ', 'wpturbo' ),
		'no_terms' => __( 'No Items ', 'wpturbo' ),
		'items_list' => __( 'Items List ', 'wpturbo' ),
		'items_list_navigation' => __( 'Items List Navigation ', 'wpturbo' ),
	);

	$args = array(
		'labels' => $labels,
		'hierarchical' => false,
		'public' => true,
		'show_ui' => true,
		'show_admin_column' => true,
		'show_in_nav_menus' => true,
		'show_tagcloud' => true,
		'show_in_rest' => true,
		'rest_base' => 'my_taxonomy',
		'rest_controller_class' => 'WP_REST_my_taxonomy_Controller',
	);

	register_taxonomy( 'my_taxonomy', array('post'), $args );
}
add_action( 'init', 'wpturbo_register_my_taxonomy' );
                

WordPress taxonomies FAQ

What is a taxonomy in WordPress?

A taxonomy is a way to classify and categorize content, such as posts, pages, and custom post types, by creating a hierarchical structure of terms.

The most common taxonomies in WordPress are categories and tags, but developers can also create custom taxonomies.

What is the difference between categories and tags in WordPress?

Categories are a hierarchical taxonomy, meaning that they can have parent and child terms. For example, a “Fruits” category can have “Apples” and “Oranges” as child terms.

Tags, on the other hand, are a non-hierarchical taxonomy, meaning that they don’t have parent-child relationships. They are simply a way to group related posts together.

What is the register_taxonomy() function?

The WordPress register_taxonomy function is a built-in WordPress function that allows users to create custom taxonomies for their WordPress site beyond the default categories and tags that are included with WordPress.

To use the register_taxonomy function, users need to provide several arguments to define the properties of the custom taxonomy. These arguments include the name of the taxonomy, the types of objects that the taxonomy will be applied to (such as posts or pages), and labels for the taxonomy (such as the singular and plural forms of the term).

Once the custom taxonomy has been registered using the register_taxonomy function, it can be used in a similar way to the default categories and tags. Users can create new terms within the taxonomy, and assign those terms to individual pieces of content on their site. This allows for more fine-grained organization and classification of content.

How are taxonomies stored in WordPress?

WordPress taxonomies are stored in the database as terms, and the relationship between the terms and the content (posts, pages, custom post types) is stored in the wp_term_relationships table.

Each taxonomy has its own set of terms, and each term has a unique ID. When a post is associated with a term, the term’s ID and the post’s ID are added to the wp_term_relationships table, along with the ID of the taxonomy to which the term belongs.

In addition to the wp_term_relationships table, WordPress also uses other tables to store information about taxonomies, such as wp_term_taxonomy and wp_terms tables.

The wp_term_taxonomy table stores metadata about the taxonomy, such as the number of times a term is used, and whether the taxonomy is hierarchical. The wp_terms table stores the name, slug, and description of each term in the taxonomy.

Where can I learn more about taxonomy registration?

Go to the official WordPress documentation and check the register_taxonomy() function reference.

Sign up to save your WordPress snippets on WPTurbo.