How to display subcategories on the category page of WordPress
Apr 20, 2025 am 07:18 AMDo you want to display subcategories on the category page of WordPress?
WordPress makes it easy for you to organize your posts using categories and subcategories. You can help visitors navigate subcategories more easily by displaying them on the category page.
In this article, we will show you how to display subcategories on the category page of WordPress.
Why do subcategories appear on category page?
When you write posts for your WordPress website, you can optimize your search engines and improve your website navigation by correctly categorizing your content. This will bring more traffic to your website and make it easier for visitors to find what they are looking for.
On some websites, it makes sense to use subcategories to simplify the structure of a website.
For example, you might have a top (parent) category called "Sports". You can then create subcategories under Sports called NFL, NBA, and MLB.
When your visitors click on the Sports category, they will see each post in the Sports category and its subcategory. However, they won't see a list of subcategories. This makes it hard to filter to NFL or NBA posts.
Showing a list of subcategories on the category page can improve site navigation. This is especially true if you decide to hide subcategories in the Category Widget of your website.
For example, visitors to your website can easily transfer from all sports posts to NFL-only. Even better, you can continue to display the same subcategories on the NFL page so that they can easily switch from NFL to NBA.
That being said, let's see how to display subcategories on the category page of WordPress.
How to display subcategories on the category page of WordPress
To display subcategories on the category archive page, you need to add the code to the topic file. If you need help adding code to your website, see our beginner's guide on how to paste web snippets into WordPress.
The first thing you need to do is go into the theme folder and look for a name called category.php.
If you don't see the file, you have to create it. Just copy archive.php and name it category.php.
Note : If your theme does not contain category.php or archive.php, you may be using the WordPress theme framework and you must create category.php manually. A great starting point for learning how to create archive files is our guide on how to create custom archive pages in WordPress.
Now, just add the following code before the category.php loop:
Now when you visit the category page, you will see a list of subcategories.
On our demo website, the Sports Categories page displays links to the NFL, NBA, and MLB subcategories.
After clicking the NFL link, you will be on the NFL subcategory page.
Here you can still see links to the sports subcategories, so you can easily switch between different types of sports. This can really simplify navigation on your website.
We hope this tutorial helps you learn how to display subcategories on the category page of WordPress. You may also want to learn how to improve your website's SEO or our expert picks of the best WordPress popup plugins.
The above is the detailed content of How to display subcategories on the category page of 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

Contents 1. What is ICN? 2. ICNT latest updates 3. Comparison and economic model between ICN and other DePIN projects and economic models 4. Conclusion of the next stage of the DePIN track At the end of May, ICN (ImpossibleCloudNetwork) @ICN_Protocol announced that it had received strategic investment in NGPCapital with a valuation of US$470 million. Many people's first reaction was: "Has Xiaomi invested in Web3?" Although this was not Lei Jun's direct move, the one who had bet on Xiaomi, Helium, and WorkFusion

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is 2.101.8, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest official version of the virtual currency trading platform v6.129.0 is a professional and secure digital asset trading application created for Android users. It provides rich market conditions, convenient trading functions and multiple security protection, and is committed to providing users with a first-class trading experience.

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.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.
