WordPress Categories Explained

Share this article

Organizing WordPress posts into different categories is essential if you have many posts. That way, your visitors (and you!) can easily search and sort your posts and only see what they want. In this article we’ll look at how we can manage WordPress categories. We’ll begin with the description of some basic things about adding, editing or deleting a category. Then, we’ll look at how to display a list of our categories, and how to customize this list, with the default widget that WordPress provides us.

Managing Categories

WordPress give us a dedicated page for managing categories, available in the menu of the administration panel. More precisely, this page is accessible from the “Posts” submenu and is named “Categories”.

Two Ways to Add a Category

If you access this page, you can see a form on the left, named “Add New Category”. The first field in this form, labeled “Name”, is as it suggests, is the name that will appear everywhere you display the category of a post or the list of your categories on the site. The usefulness of the other fields is not necessarily obvious. First, the “slug”. As it is described right below the field, this string is useful when you activate URL Rewriting to have readable URLs for your website’s pages. For example, let’s assume that you set “category” in the “Category base” permalinks settings (from the Settings -> Permalinks menu). Then, if you enter “my-life” into the slug of your new category, visitors can access the page listing all the posts in this category by using the URL http://example.com/category/my-life. Note that, as this string is used in a URL, some rules must be respected, but you can in practice indicate whatever you want, as WordPress will automatically clean your string to make it “URL-friendly”. Right after this field we find a list labeled “Parent”. This list allows you to choose one of your existing categories to be the parent of your new category. That way, you can build your own hierarchy, which is a good thing when you have several categories. For example, if you added the category “My life” and if you want to put in one category your posts about the awesome life of your goldfish, then you can create the category “My goldfish” with “My life” as a parent. It’s exactly like directories and subdirectories on your computer. Finally, you can enter a description of your category in the last field. Not all themes use this field, so be sure that your theme does before spending time filling this in! Add Category To finish with the addition of a category we can note that there is also another way to add a category: when you write a new post (or when you edit an existing one). In fact, when you choose the category where you put your post, you can find an “Add New Category” link that allows you to add a new category by simply indicating its name and, if necessary, its parent. The slug will then be its cleaned name, and its description will be empty. However, you can still edit this category and change it later.

Editing a Category

It’s always possible to edit a category, to update its information. Editing a category can be done from the same page as previously, in the “Categories” submenu of the “Posts” menu. You’ll see on the right of this page the list of your categories, similar to the list of your posts in the corresponding page. By clicking the name of a category you will be redirected to another page containing a form, already pre-filled with the current information. All you have to do is modify the category you want and submit the form once you’re done. If you only want to change the name or the slug of a category you can also choose the “Quick Edit” option appearing when your mouse is over a category. Quick Edit

Deleting a Category

Right next to the “Quick Edit” option we find the “Delete” one. If you want to delete a category, click on this link, confirm your choice, and you’re done. You can also select all the categories you want to delete and choose “Delete” in the “Bulk Actions” list. Be careful: deleting a category is not an action that can be reversed. Note that deleting a category won’t delete the posts using this category. If these posts use other categories, the deleted category will just disappear from their used categories list. If they don’t use any other category, then they will fall into the default category, named “uncategorized”. Note that this is the reason why this category can’t be deleted (but you can still edit it).

A Widget to Display the Categories

As for the Links Manager, WordPress provides us a default widget to display a list of our categories wherever we want in our theme. Let’s test it by accessing the widgets manager from the “Appearance” menu. Simply named “Categories”, this widget allows us to customize its display with four settings. By default, the title of this widget is set to “Categories”, but you can change it by entering the title of your choice in the “Title” field. The three other settings are checkboxes that allow you to customize the list of categories. Note that, whatever you choose in these options, only the categories that contain at least one post are shown (if we forget the “parent effect” explained below). To explain the “parent effect” we begin with the last option: “Show hierarchy”. This option is useful if you set some categories as parents of others (see the glorious example of your life and your goldfish above). As you may guess, by activating this option, WordPress will display the exact hierarchy of your categories. Without this option, all of your categories are displayed in one column, without any relation between them. No Hierarchy With this option activated, the hierarchy is shown, with nested lists. Hierarchy When you activate this option you must think about an effect: parents are shown, even if they do not contain any posts themselves. For example, the two screenshots above were taken with the same configuration, with the same posts and categories. The “Parent” category does not contain any post by itself, but its children do, so WordPress displays it in the list, to show the hierarchy. It is an expected effect, but it’s always a good thing to see how it works. The second option, labeled “Show post counts”, is relatively clear: it adds, between parenthesis, the number of posts contained in each category. Post Count
Note, again, the “parent effect”: a parent category shows the sum of all of its children’s counts. Finally, the first option: “Display as dropdown”, which allows you to display the list of categories as a dropdown list. This option is particularly useful if you have a lot of categories. Your visitors have to open the list and select the category they want to see. Then, automatically, WordPress will redirect them to the right page. Note that this option is compatible with the two others: hierarchy and posts counts can still be shown in the dropdown list. Dropdown List

In Conclusion

Categories are important to help organize your website. Now that we’ve seen how to add, edit and delete a category, you have no excuse to not sort your posts! If knowing how to manage categories is important, as a developer, the most important part comes with the question: how to retrieve these categories? How to list them? How to display information about one particular category? The answer to this question can be found in using the WordPress Categories API, an API grouping some functions that can do the things we just listed. The good news is that the Categories API is the topic of our next article!

Frequently Asked Questions about WordPress Categories

How can I add a new category in WordPress?

Adding a new category in WordPress is quite simple. Navigate to your WordPress dashboard, then go to Posts > Categories. Here, you’ll find a form to add a new category. Fill in the necessary details such as the name of the category, its slug (the URL-friendly version of the name), the parent category (if any), and the description. Once you’re done, click on the ‘Add New Category’ button.

How can I edit an existing category in WordPress?

To edit an existing category, go to Posts > Categories from your WordPress dashboard. Here, you’ll see a list of all your categories. Hover over the category you want to edit and click on the ‘Edit’ link that appears. You can then change the name, slug, parent category, or description as needed. Don’t forget to click the ‘Update’ button to save your changes.

What is the difference between categories and tags in WordPress?

Categories and tags are both ways to organize your content in WordPress, but they serve different purposes. Categories are meant for broad grouping of your posts. Think of these as general topics or the table of contents for your site. Tags, on the other hand, are more specific and describe specific details of your posts. They are more like your site’s index words.

How can I assign a post to a category in WordPress?

When you’re writing or editing a post, you’ll see a ‘Categories’ box on the right side of your screen. Here, you can select the category or categories that you want to assign to the post. If you don’t see the category you’re looking for, you can also add a new one directly from this box.

Can a post belong to multiple categories in WordPress?

Yes, a post can belong to multiple categories in WordPress. This can be useful if your post covers multiple topics that you have categories for. To assign a post to multiple categories, simply check all the relevant categories in the ‘Categories’ box when you’re writing or editing the post.

How can I change the permalink structure to include the category name?

To include the category name in your permalink structure, go to Settings > Permalinks from your WordPress dashboard. Here, select the ‘Custom Structure’ option and enter ‘/%category%/%postname%/’ in the text box. This will make your URLs follow the format ‘yourwebsite.com/category/post-name’.

What happens if I delete a category in WordPress?

If you delete a category in WordPress, the posts that were assigned to that category will not be deleted. Instead, they will be automatically assigned to your default category, which is ‘Uncategorized’ unless you’ve changed it.

How can I change the default category in WordPress?

To change the default category, go to Settings > Writing from your WordPress dashboard. Here, you’ll see a ‘Default Post Category’ dropdown. Select the category that you want to set as the default, then click the ‘Save Changes’ button.

Can I create a category hierarchy in WordPress?

Yes, you can create a category hierarchy in WordPress by using parent and child categories. When you’re adding or editing a category, you can select a parent category from the ‘Parent Category’ dropdown. The new or edited category will then become a child of the selected parent category.

How can I display a list of all categories on my site?

WordPress includes a built-in widget for displaying a list of all categories. To add this widget, go to Appearance > Widgets from your WordPress dashboard. Here, find the ‘Categories’ widget and drag it to the desired location in your sidebar or footer.

Jérémy HeleineJérémy Heleine
View Author

Currently a math student, Jérémy is a passionate guy who is interested in many fields, particularly in the high tech world for which he covers the news everyday on some blogs, and web development which takes much of his free time. He loves learning new things and sharing his knowledge with others.

categoriesChrisBWordPresswordpress categories
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week