How to hide or set styles of subcategories in WordPress
Apr 20, 2025 am 07:30 AMDo you want to hide subcategories in WordPress, or style them so that your list of categories is easier to read?
In WordPress, your posts can be divided into different categories and subcategories. This helps with navigation and SEO, but a long list of subcategories doesn't always look great on your website.
In this tutorial, we will show you how to use code snippets to hide subcategories and change their styles.
Why use subcategories in WordPress?
When you write posts for your WordPress site, you can use categories and tags to organize them. When you categorize content correctly, you can improve your SEO, which will bring more traffic to your website.
Organizing your posts can also improve navigation of your website so that visitors can find what they are looking for more easily. You can even create subcategories when your website structure becomes more complex.
For example, a travel blog might have a category about destinations to visit in the United States. As content grows, it may make sense to create subcategories for cities like Chicago, Los Angeles, and New York.
If you display categories in WordPress widgets, you can use flat lists or hierarchies. Here is how each option looks on our demo website.
You can do this by visiting the Appearance ? Widgets on the WordPress dashboard and selecting the Show Hierarchy box on the Category Widgets.
But no matter which option you choose, the list ends up being long and difficult to manage and doesn't look great on your WordPress site either.
In this guide, we will show you how to hide subcategories to make your category list easier to navigate. We will also show you how to style the subcategory for a cleaner look.
How to use CSS to hide subcategories in WordPress
In this article, we will use CSS code snippets to hide subcategories and style them. You can add snippets directly to the theme's style.css file, snippet plugins such as WPCode, or add them using the theme customizer in the WordPress dashboard.
Adding CSS can be tricky for beginners, and making a mistake can potentially ruin your WordPress site. If you are new to using code snippets, you may want to check out our guide on how to easily add custom CSS to your WordPress site.
That being said, let's see how to hide subcategories in WordPress.
You need to copy the following code and paste it into the theme's style.css file, code snippet plugin, or WordPress theme customizer.
You can now access your WordPress website to ensure that the subcategory is hidden. Below are screenshots of our test website before and after.
This looks cleaner, but now your visitors don't see the subcategory. You may want to check out our guide to see how to display subcategories on the WordPress category page.
If you do this, when your visitors click on the “US” category, they will see links to subcategories such as Chicago, Los Angeles, and New York City on that page.
How to style subcategory in WordPress using CSS
You can also use CSS to customize the appearance of categories and subcategories. This will depend on your own knowledge of CSS and what changes you want to make to how they look in the current topic.
For example, if you show subcategories in a hierarchy, adding a vertical bar allows you to quickly see which categories are at the same level. Let's see how to do this.
Changing the style of subcategories is the same as hiding them. You need to copy the code below and paste it into style.css, WPCode plugin, or WordPress theme customizer.
Feel free to adjust the code to customize the style to your preferences.
You can also use CSS to style other elements of your WordPress theme. For example, you can use CSS to set different styles for each category.
We hope this tutorial helps you learn how to hide subcategories and change their styles in WordPress. You may also want to check out our list of essential WordPress plugins to extend your website, or see a tutorial on how to display related posts in WordPress.
The above is the detailed content of How to hide or set styles of subcategories in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

As the market conditions pick up, more and more smart investors have begun to quietly increase their positions in the currency circle. Many people are wondering what makes them take decisively when most people wait and see? This article will analyze current trends through on-chain data to help readers understand the logic of smart funds, so as to better grasp the next round of potential wealth growth opportunities.

Under the current severe regulatory environment, the difficulty of directly applying for a specific business license is increasing day by day, and the success rate is not ideal. Many platforms have therefore fallen into development bottlenecks. This article will analyze in detail an efficient "curve approval" strategy, aiming to help you understand how to obtain the required license through indirect compliance. This article will explain its operational process and core points in steps, providing you with a feasible compliance path.

The currency circle seems to have a low threshold, but in fact it hides a lot of terms and complex logic. Many novices "rush into the market" in confusion and end up losing money. This article will give a comprehensive explanation of common terms in the currency circle, the operating logic of real money makers, and practical risk control strategies to help readers clarify their ideas and reduce investment risks.

Stablecoins are cryptocurrencies that are pegged to assets such as the US dollar and aim to maintain stable value. They are mainly divided into three types: fiat currency collateral, cryptocurrency collateral and algorithms. 1. Fiat currency collateral types such as USDT and USCD are supported by US dollar reserves; 2. Cryptocurrency collateral types such as DAI need to over-collateralize other currencies; 3. Algorithm relies on smart contracts to adjust supply but have high risks. The reasons why it is hotly discussed on platforms such as Douyin include: as a hedging tool when the crypto market falls, a bridge for novices to enter the crypto world, a way to obtain high-yield financial management in DeFi, and the application of low-cost cross-border payments. To obtain stablecoins, you can trade through mainstream exchanges such as Binance, Ouyi, and Huobi.

Yes, some merchants in Yiwu, Zhejiang have indeed begun to accept stablecoins such as USDT as a way to settle trade payments, but this phenomenon is not promoted by official policies and has not been popularized by all merchants. It is mainly a private practice adopted by individual merchants engaged in specific international trade to solve the problem of cross-border payments. 1. The reasons why merchants choose stablecoins include stable value, convenient transactions, low cost and the ability to bypass traditional payment barriers; 2. There are currently no official statistics, and it is estimated that hundreds to thousands of merchants are involved, focusing on industries with high dependence on foreign trade and customers from countries with limited payments; 3. Mainstream trading platforms include Binance, Ouyi, Huobi, Gate.io, KuCoin and Bybit. These platforms provide C2C or P2P transaction services to support fiat currency and stability

HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams.

With the increasing emphasis on cryptocurrency regulation around the world, choosing the right operating license has become the key to the success of the project party. This article will explore the current value rankings of mainstream cryptocurrency licenses in the world, analyze their respective advantages and disadvantages, and reveal a country that stands out in regulation, cost and flexibility, and is quickly becoming the new favorite in the industry in 2025. At the same time, it will explain the reasons for its popularity and provide decision-making reference for practitioners.

The "reverse reference" in the currency circle, as the name suggests, refers to those reference objects whose views or operations are often opposite to the actual market trend. When such people or groups are extremely optimistic, the market may face a decline; when they are extremely pessimistic, the market may instead rebound. This is not to say that these people deliberately provide wrong signals, but that their judgments may deviate from the mainstream trends in the market, or that their operating behavior happens to be a catalyst for market reversal in a specific situation.
