Taxonomy

Home » Taxonomy

A Taxonomy is a type of classification method used as a way to group similar posts and custom post types together. Taxonomies refer to any sort of categorization in WordPress including tags, categories and custom taxonomies.

This glossary entry covers the following topics:

What is a Taxonomy

Taxonomies provide an easy way to sort content into defined topics. This helps you organize your content. It also helps visitors in finding the topics that they might be interested in.

The term is relatively unheard of for WordPress beginners but is something that gets used a lot.

It is derived from the part of science that focuses on naming and grouping organisms. In the 1700s a Swedish naturalist named Carolus Linnaeus developed a way to name and organize species creating the term Taxonomy. WordPress initially adopted taxonomies to group posts and then expanded to grouping post types too.

WordPress has two taxonomies built into the posts post type by default. These taxonomies are Categories and Tags. The pages post type is considered singular and does not have taxonomies associated with them. They can however be added through custom taxonomies.

Custom taxonomies

Custom taxonomies are unique taxonomies that you can create to add to any post type. They are usually added to custom post types but can be added to posts and pages too.

Custom Post Type and Custom Taxonomy

Custom taxonomies help you to group your post types the same way as categories and tags do but are used to provide extra flexibility.

Example: You have a portfolio custom post type that you add all of your greatest portfolio pieces to.
You can add filters like: print, digital and web etc. You want to create a filter for the portfolio so people can sort by the type of your portfolio items.
You could categorize each item using the category’s taxonomy but you may not want to mix up your posts with portfolio pieces because they are separate.
In this case you would register a new taxonomy called type. This will allow for you and your sites users to sort your portfolio pieces by each type.

Custom taxonomies can be hierarchical. This means that each taxonomy item can have sub taxonomy items under it. So if we are using our portfolio example from above, the web filter could have sub-filters of HTML and another as WordPress as an example.

These sub-filters are assigned to any number of portfolio items and is simply a way to be more specific in categorizing your content. Hierarchical taxonomies are optional and it is recommended to use only if it suits your content otherwise you may end up with a taxonomy item with only one portfolio piece in it.

Categories

A category is one of the two built in taxonomies in WordPress. It is used to group similar topic posts together.

WordPress Posts > Category

A website that writes content for a certain industry will want to sort each topic they write about into its own category. This is to allow people to find content on that category easier. Doing so creates better usability across your site allowing content to be found that may not be found otherwise.

Example: A website that talks about the computer games may want to create categories for Action, Adventure, Sports, Role-playing etc.

When you first setup WordPress, an Uncategorized category is automatically created. If you do not create your own categories then your post will be assigned to the Uncategorized category when published.

When you start to write, you might find that a particular category is used more often than others. A website admin can change the default category in the settings > writing screen.
You can assign multiple categories to the one post just like you can assign multiple tags to one post too.

How to add categories

Categories are added to posts when you’re creating or editing a post. On the right hand side of the post editor is a categories meta box which is where you can assign categories to your post in this box you’ll see a list of previously created categories or you can create your own category and it will be added to this list when you’re creating future posts. To assign a category to post simply click the check box next to the category name you can add a new category by clicking on the + add new category link.

Adding Categories in WordPress editor

There is also an admin page in the Posts > Categories sidebar menu where you can edit or create your own categories. On this page you add the name of the category. If you choose, you can skip the other fields and just click the add new category button. WordPress will handle the rest of the fields for you. Or if you choose you can have finer control by adding the slug and description of the category and also choose a parent category if it is a subcategory.

The “slug” is the URL-friendly version of the name which is accessed when you view that category on the front-end of your website. for example https://wpabsolute.com/category/getting-started/ is the getting started category URL and getting-started is the slug of that category. It is usually all lowercase and contains only letters, numbers, and hyphens.

The description is a field where you can describe what that category is about. It is not overly common in themes and may not be utilized in your theme. When it is used, it is generally displayed on the single category page when viewed on the front-end of your site.

How to edit categories

On the same screen as where you add categories in the Posts > Categories page, you can administer existing categories. Categories can either be edited or removed.

WordPress Category Edit Page

Hovering over the category that you want to edit brings up the quick links menu where you can either edit, quick edit, delete or view the category on the front-end of your site.

Manage Tags WordPress

Clicking the edit link brings up the Edit category page. This is where you can edit the title, slug, parent category and description of that category. If you have any plugins that add additional features to categories such as SEO plugins then they may introduce their meta-boxes at the bottom of this page too.

Once you are finished making changes, you click the update button to save or the delete button to completely remove that category from your site. If you do delete the category, none of the posts assigned to it will get deleted however the category will be removed from all of the posts.
If the category you are trying to remove is your default category then you can not delete it until you have set another default category. You can change the default category in the Settings > Writing admin sidebar menu. Once it has changed, you can remove that category.

Clicking the quick edit link displays a drop-down where you can edit the name of the category as well as the slug. Once you have made the necessary changes you can either click on the update category button or cancel to remove your changes.

Clicking on the delete link will firstly come up with a warning stating that you are about to permanently delete it from your site and that the action cannot be undone. If you click ‘Cancel’ it won’t delete the category or if you click ‘OK’ it will be deleted.

Clicking on the view link will take you to that categories single page on your website. Each theme handles categories differently but it should display all the posts that are categorized under that category.

How to display categories

Categories can be displayed on your site in a number of ways. You can either have them display as a widget or as a menu and their index pages will automatically update with the latest posts categorized in that category.

WordPress Categories Widget

To display your categories in the sidebar, go to Appearance > Widgets and drag the Categories widget to your sidebar.

The widget allows you to display a title above the widgets and has a couple of options to customize the display of the categories.
Categories can be displayed as a drop-down or as a list showing all of your categories that have posts filed under them.

You can display the amount of posts that are in that category next to the category name. Finally, you can lay out the list in a hierarchical nature where the sub-categories are positioned under the category.

Categories can also be added to any navigational menu. To add categories, go to Appearance > Menus. Click on the categories drop-down and select the categories you want to add to your menu. Once you have chosen your categories, click the Add to menu button.

WordPress Category Add to Menu

The categories will be added to your menu once you save the menu.

On the front-end of your website you will be able to click on any of the categories from either your menu or your widget list and it will take you to that categories page.

Your theme should come with a category.php file in it. This is what is controlling the output of your single category page. You can modify this file and changes will show on the category page.

If you need to do specific modifications to a single category then your can create a duplicate of category.php and name it category-example.php where example is the slug of your category. Making changes to this file will only show when viewing the index of that specific category.

Child Categories

Categories are hierarchical. This means that each on can have child categories. The child categories should be thought of as a sub-topic under a more broader topic.

Example: If we have a category with the name web and we need to break that down further then we can create a sub-category with the name of HTML and another as WordPress for example.

These sub-categories are assigned to any number of posts and is simply a way to be more specific in categorizing your post content. Hierarchical categories are optional and it is recommended to set these up only if it suits your content otherwise you may end up with a sub-category with only one post in it. Which may not be considered the best user experience if it is too compartmentalized.

WordPress Sub Categories

Categories can be turned into sub-categories either when you create or edit the category in the Posts > Category page. You can also create a child category in the same way you create a category on the post edit screen. Just make sure you select the parent category when adding it otherwise you will have to edit the category to update it to a child category.

Tags

Tags are the second taxonomy that comes default in WordPress. They are assigned to posts and are handled in a very similar fashion to categories. Although similar, tags and categories are two separate things and serve different purposes. A category covers a broad range of topics while a tag is much smaller in scope. It is more focused on specific topics. They are like what modern social media users call a hashtag and should be considered as a keyword discussed in that particular post.

WordPress Post Tags

Tags are not hierarchical so that means you can not have sub-tags like what you can with categories. It is a flat organizational system.

Unlike categories, tags are not automatically assigned to a post and their use is completely optional. If you have a lot of posts that are well categorized then it is a good idea to add tags to your posts as a way of sorting similar posts.

There are no limits to the amount of tags a post can have and there are no limits to the amount of posts tagged by the tag. As a general usability guide, it is better to have less tags or combine multiple tags of similar substance into one so that your site doesn’t have a lot of “thin” pages with little to no unique content.

Example: A post about a computer game filed in the Sports category could have a tag for soccer, football and field sports.

How to add tags

Tags are added to posts when you’re creating or editing a post. On the right hand side of the post editor under the Publish meta-box is the tags meta box. This is where you can assign tags to your post. In the field you’ll be able to create your own tags. If you are typing a tag and it already exists, you can click it from the drop-down list. Once done, click add and it will be added to the tags list.

Adding Tags in WordPress editor

If you save the post, the tags that you added will be able to be selectable when you’re creating posts in the future.

There is also an admin page in the Posts > Tags sidebar menu where you can edit or create your own tags. On this page you add the name of the tag. If you choose, you can skip the other fields and just click the Add New Tag button. WordPress will handle the rest of the fields for you. Or if you choose you can have finer control by adding the slug and description of the tag.

Tags Manager WordPress

The “slug” is the URL-friendly version of the name which is accessed when you view that tag on the front-end of your website. for example https://wpabsolute.com/tag/plugins/ is the plugins tag url and plugins is the slug of that tag. It is usually all lowercase and contains only letters, numbers, and hyphens.

The description is a field where you can describe what that tag is about. It is not overly common in themes and may not be utilized in your theme. When it is used, it is generally displayed on the single tag page when viewed on the front-end of your site. It can serve the purpose of providing a brief overview of the tag and can help with SEO of that page.

How to edit tags

On the same screen as where you add tags in the Posts > Tags page, you can administer existing tags. Tags can either be edited or removed.

Hovering over the tag that you want to edit brings up the quick links menu where you can either edit, quick edit, delete or view the tag on the front-end of your site.

Manage Tags WordPress

Clicking the edit link brings up the Edit tag page. This is where you can edit the title, slug and description of that tag. If you have any plugins that add additional features to tags such as SEO plugins then you will see their meta-boxes on this page too.

Once you are finished making changes, click the Update button to save or the delete button to completely remove that tag from your site. If you do delete the tag, none of the posts assigned to it will get deleted however the tag will be removed from all of the posts.
Unlike categories, you do not need to set a default tag so you can remove all tags in one go.

Clicking the quick edit link displays a drop-down where you can edit the name of the tag as well as the slug. Once you have made the necessary changes you can either click on the update tag button or cancel to remove your changes.

Clicking on the delete link will firstly come up with a warning stating that you are about to permanently delete it from your site and that the action cannot be undone. If you click ‘Cancel’ it will not delete the tag or if you click ‘OK’ it will be deleted.

Clicking on the view link will take you to that tags single page on your website. Each theme handles tags differently but it should display all the posts that are tagged under that tag.

How to display tags

Similar to Categories, you can add tags to your page in two ways. You can display all of your tags in a tag cloud or you can add them as items in a navigational menu.

The tag cloud widget can be added to the widgitized areas on your site. Add the tag cloud by going to the Appearance > Widgets admin page. Drag the Tag Cloud widget to your widget area.

Tag Cloud Widget Area WordPress

The widget can be given a title and you can choose which taxonomy to use. In this case, we are using the tags taxonomy but you can also display any of your other taxonomies in the same way including categories.
You have the option to show how many items have been tagged with that tag too. Once you have configured your Tag Cloud, click the Save button for the tag cloud to be on your website.

The second way of displaying tags is by adding them as menu items in your navigational menus. Go to Appearance > Menus to access the menus page.
By default, the option to add tags is not displayed. You can turn this on via the screen options drop-down in the upper right hand corner. Tick the tags option for the tags to be shown.

Navigation Menu Screen Options Tags

Once the tags are shown, you can add any number of tags to your navigational menu by clicking the Add to menu button. Once the tags have been added to the menu, click Save Menu to save your changes. The menu will now have your chosen tags displayed in it on the front-end of your site.

Tags that are added via the widget and menu items are displayed as links. When a tag is clicked, it will take you to that corresponding tags archive single page where it lists all of the posts from that tag.

Converting Categories and Tags

When your site grows, you may find that your initial setup up of how you added your tags and categories may not make as much sense as it did. Or perhaps you made a mistake when initially setting up and want the tags to be categories now. Whatever the case, you can easily convert your tags to categories and categories to tags.

You could just remove the category and add a new tag or visa-versa but that would mean that you would then have to link all of the posts that had that taxonomy again. By using the converter, it does this step for you and all of your posts will automatically have the converted taxonomy that was previously assigned to it.

Categories Tags Converter WordPress

To convert your taxonomies, go to Tools > Import and click on the install now link under Categories and Tags Converter. This will install the Categories to Tags Converter Importer plugin. Activate the plugin and run the importer.

Select either the “Categories to tags” or the “Tags to categories” button to select which way you want to convert.
Choose which tags/categories you want to convert and then click the convert button. The tags/categories are now converted. You can easily convert them back by choosing the other option if needed.

Posted on