Beginners Guide to Creating Categories and Subcategories in WordPress

One of the best ways to organize your content on a WordPress website is through the use of categories. Categories allow site visitors to browse through the website’s content by topic or a grouping rather than doing it chronologically. Before going further with this tutorial, it is important to note that categories are different from tags. Categories are used for grouping of posts on a WordPress website while tags are used for describing specific details of a post.

There are two ways through which you can create a category in WordPress. They include;

  1. Creating a category from the categories menu under Posts in the dashboard.
  2. Creating a category directly from the post creation and edit screen

Creating Categories from the Categories Menu

To create a category, login to the admin dashboard and hover over Posts on the left hand side menu options at the dashboard. This will show a dropdown menu with All Posts, Add New, Categories and Tags options. Click on Categories to go to the categories screen.

Accessing categories from the admin dashboard

Clicking on the Categories option will take you to a screen that looks like the one below;

Categories page

This screen allows you to create a new category as well as view all your categories and sub categories. Before we create a category, it would be good to understand all the fields we have on this screen. On the left hand side of the screen, we have the following;

  • Name: This is where we will enter the name of our category. This is how the name will appear on the website.
  • Slug: This is a URL-friendly version of the category name. It is usually all lowercase and contains only letters, numbers, and hyphens. If you do not assign one, WordPress will automatically do it for you.
  • Parent Category: Categories come with a hierarchy which allows you to choose parent and child categories. For example, you can have a parent category “Fruits” and under it have a child category “Oranges”. When assigning posts to categories that have a parent and child categories, you are allowed to choose whether you would like the post to appear under both categories or under just the child category. If you choose to file a post under the child category but not under the parent category, then your post will appear only on the archive pages of child category. This particularly helpful when you want to avoid duplicate content. If you file a post under both parent and child categories, then the archive pages of both categories will be completely identical.
  • Description: This is a text field that allows you to add a description of the category. This is particularly helpful in understanding what each of the categories is about.

On the right hand side of the screen, we have a table for the available categories which has the following columns;

  • Name: This is the name of the category.
  • Description: This shows the description entered in the description text area when creating the post.
  • Slug: This shows the category slug described above.
  • Count: This shows the number of posts under that particular category.

We are now going to create a category called Fruits. At the above page, enter the category name, the slug, leave the default selection for the Parent Category which is none and then enter the category description.

Creating a category

Once you have filled in the category details, click on the Add New Category button at the bottom left to save the category.

Save new category

If you look at the table on the right hand side of the screen, you will notice that our newly created category has been added to the list of categories with count column being zero since we do not have any post under it yet.

List of categories

We are now going to add a new category called Orange to our list of categories, but as a child category to Fruits. To do that, fill in the categories details just like we did when creating the Fruits categories. However, since this is a child category, we are going to click on the Parent category drop down menu and select Fruits, as shown in the screenshot below;

Creating a child category

Click on the Add New Category button to save the new child category. If you now look at the categories table on the right hand side of the screen, you will notice that the child category fruits has been added just beneath the Fruits category, showing that it is a child category to the fruits category.

List of categories showing child category

Editing and Deleting a Category

I would like to change the description I added to the Fruits category. To do that, we are going to edit the category. Hovering over a category displays an additional menu with Edit, Quick Edit, Delete and View options as shown below.

Category menu options

Clicking on the Edit option will take you to another screen where you can edit the name, slug, parent category and add a description as shown on the screenshot below;

Editing a category

Click on the update button when done to save your changes. Clicking on the Quick Edit option only allows you to edit the category name and the slug.

Editing a category through Quick Edit

To delete a category, simply choose the Delete option which will prompt you through a pop up window to confirm that you want to permanently delete the category and the category will be deleted from WordPress.

WordPress adds a category named Uncategorized by default. If you do not assign a category to a post when creating it, the post is automatically assigned to the Uncategorized category. Also, if you delete a category from WordPress, all posts that were under the deleted category are automatically assigned to the Uncategorized category.

Creating Categories from the Post Creation/Edit Screen

To learn how to create a post in WordPress, you can see this tutorial. You can also create a new category from the post creation/edit screen. While at this screen, on the right hand side of the screen, there is a Categories Panel. This panel shows you a list of all the categories that you have, with the one assigned to that particular post having a checked checkbox on the side it as shown below;

Categories Panel

If you realise that the category you would like to use for your post does not exist, you can create it from this panel rather than going to the Categories screen. The only limitation with this method is that it does not allow you to enter a slug of your choice here as well as the description for the category. These can, however, be added through the Categories screen by editing the particular category. We are going to create another category through the post edit screen called Apples as a child category to the Fruits category.

To do that, we are going to click on the “+Add New Category” link at the bottom of the categories panel.

Adding new category

This will open a text box just below the Add New Category link where we are going to type in the name of the category and then choose the parent category just below the name.

New category details

After choosing the Parent Category, click on the Add New Category button at the bottom of the Categories panel.

Saving new category

The new category will now be among the listed categories on the panel. It will also be selected for that particular post.

Categories view from post edit screen

If we go back to the categories screen now, we will be able to see the new category we have just added under the parent category as shown below;

All categories view

Displaying Categories on a Post’s Sidebar

Your WordPress website will now show the categories for a particular post automatically. You can also choose to display all your categories on a post’s sidebar for easy navigation. To do that, we will visit Appearance >> Widgets from the admin dashboard page.

Accessing widgets from the dashboard

This will take you to a widgets page where you can drag and drop a categories widget to a sidebar.

Widgets screen

After dragging and dropping the categories widget, it will expand to open the widget settings where you can add a title, choose to display the categories as a drop-down menu, show post counts and show hierarchy. I am going to add Categories title and select show hierarchy on my widget as shown below;

Adding a categories sidebar

Click on the Save button to save your changes.

Conclusion

Finally, it is important to note that even though categories help us organize our website content, it is easy to have them get out of hand. This can happen when they become a tangled mess of words without a meaning. It is therefore important to map out your website from the start and create categories.

TheWphosting Staff

2 thoughts on “Beginners Guide to Creating Categories and Subcategories in WordPress”

Leave a Comment