Technology

How to hide or customize the format of subcategories in WordPress

2025-03-20 02:33:38


Do you want to hide subcategories in WordPress or customize the style to make your category list easier to read?

In WordPress, you can organize posts using main categories and subcategories, which improves navigation and is beneficial for SEO. However, from our experience, an excessively long list of subcategories can make your website look cluttered.

In this article, we will show you how to hide subcategories and customize their style using CSS code.




Why use subcategories in WordPress?

When you write a post on WordPress  Organizing content into categories can improve SEO and bring more traffic to your website. It also helps visitors find what they are looking for more easily.

You can create subcategories as your website structure becomes more complex. For example, a travel blog might have categories about tourist attractions in the United States, and as the content increases, subcategories might need to be created for different cities such as Chicago, Los Angeles, and New York.

If you display categories on a WordPress widget, you can choose to show them as a regular list or in a hierarchical format. Here is an example of the display.



How to display subcategories in a hierarchical format

You can enable it by going to Appearance » Widgets on the WordPress dashboard and checking the 'Show hierarchy' box.

However, no matter which option you choose, your category list might be too long and look messy. We will show you how to hide subcategories and customize them to look better.



How to hide subcategories in WordPress using CSS

You can use CSS code to hide subcategories by adding this code to the theme's style.css file, using a code plugin like WPCode, or in the WordPress Theme Customizer editor.

CSS code to hide subcategories


.children {

display: none;

Context:   }  \nTexto a traducir: }


How to add CSS code through the Theme Customizer

  • Go to Appearance » Customize
  • Scroll down and click on Additional CSS.
  • Place the desired CSS code here.
  • Press Publish

After adding the code, check your website to confirm that the subcategories are hidden.



How to customize the styles of subcategories in WordPress with CSS

If you want the subcategories to look more organized, you can use CSS to style them.

Example CSS code for customizing subcategories


.children {

padding: 0 0 0 5px;

margen: 0 0 0 2px;

border-left: 1px solid #333;

Context:   }  \nTexto a traducir: }


How to add CSS code

Follow the same steps as hiding subcategories by adding this code instead.

When finished, check the results on your website and further customize the CSS as needed.




We hope this article helps you easily hide or customize subcategories in WordPress. If you're interested in plugins that can help your website grow, check out our list of essential WordPress plugins or read our guide on how to display related posts in WordPress.

Leave a comment :