How to Hide or Style your Subcategories in WordPress

Before we delve into the ways of how you can hide or style your subcategories in WordPress, we will first address the definition of subcategories. In addition, we will speak of their benefits and ways to add them. After all, it is best to know all the pros of this feature before you decide that the cons should prevail.

What are subcategories in WordPress and how to add them?

Categories have the purpose of a broad grouping of your posts. You can regard them as general topics of the table of contents for your site. In essence, they are there to help you identify what your blog is really about. Categories are also great for assisting readers with finding the right type of content on your site. In addition, categories are hierarchical, so you are able to add subcategories.

A laptop with WordPress homescreen on.
Before you decide to hide or style your subcategories in WordPress, it is best that you know what purpose they serve.

The point of the subcategories is to further define the groups of your posts. Using them is not obligatory, of course. However, adding them will not only sort your content. It is by using them that you can develop a proper site structure that is meaningful and semantic. In addition, the users will find it much easier to find the content you are offering.

What are the SEO benefits of a category-based site structure?

The benefits are the easiest to see if you are using SEO Friendly URLs. With them, your subcategory (child category) will look like this:

Not only does this have much more meaning to it, but it also helps both search engines and users understand what your page is all about. Not to mention that you can also add keywords into your URL. These help people find your content on search engines.

However, if this does not seem appealing to you for any reason, know that you can get rid of the ‘category’ prefix from your category URLs. Simply install the FV Top Level Categories plugin, and it will remove the category base from URLs of your category archive pages. To illustrate this further, you will get your category archive page looking like this:

Subcategories in an example

Before you style or hide your subcategories in WordPress, let’s see what we are talking about on an example. Let’s suppose you have a moving company that offers a broad specter of services, regarding moving, packing, storage, and so on. You probably want your potential customers to be able to find articles regarding those services without much hassle.

A man looking at a WordPress webiste
Subcategories will allow your users to navigate your site with greater ease and logic.

For example, you can add Moving Services, and then post articles for Local Moving, Long-Distance moving, Residential Relocations, and so on. This is a great time to put subcategories to use. Moving Services would become a parent category, and these further definitions can become child categories or subcategories. It is important noting here that a post filed under a child category does not need to be filed under the parent category. That is, if you assign a post Residential Relocations as a category which is a child category of Moving Services, then you are free to choose whether you want the post to be filed under both or just the child category. If you decide to file a post under the child category but not under the parent category, your post will then appear only on the archive pages of child category. This will turn out to be rather helpful when you want to avoid duplicate content.

Now, let us suppose that you have created a parent category Moving Services and it only has one child category, Local Moving. If you file a post under both parent and child categories, then the archive pages of both categories will be completely the same.

Adding categories in WordPress

When writing a post in WordPress, scroll down the post edit screen all the way to the categories meta box and click on Add New Category link. That’s it. You can also add a new category without editing a post. Simply go to Posts, and then Categories page, and add your new category. This method is great if you want to create all your categories prior to adding content.

Adding subcategories in WordPress

This process will not differ from the latter one. That is, you can edit subcategories the same way you added your parent categories. On the post edit screen, scroll down to the categories section. Once there, click on the Add New Category link. Upon doing so, you will see a text field for adding a new category name and a dropdown menu to select the parent category. Additionally, you can also visit Pages > Categories page. Add the name for your subcategory and then select the parent category from the Parent dropdown menu.

A picture of WordPress
Adding categories and subcategories is super easy and achievable through a couple of clicks.

Hide or Style your Subcategories in WordPress with these simple steps

Now, as we have established, subcategories are great. They help us sort content and keep our whole website much more neat and tidy. However, they do have a tendency of looking ugly in the template, so to speak. For this reason, and any other you have yourself found, we will speak of the way you can hide or style your subcategories with one single code snippet.

You will first have to open your style.css, and then add the following code to hide the subcategories:

.children {

The same code can be used when you want to style your subcategories in WordPress:

.children {
padding: 0 0 0 5px;
margin: 0 0 0 2px;
border-left: 1px solid #333;

Know that you are free to change the code to meet your standards and preferences. While you probably thought that hiding or styling your subcategories in WordPress would be a rather complicated thing to do, now you see that it is quite easy really.