How To Delete Categories On WordPress?

Every now and then when writing new blog posts you have to categorize posts a certain way so they show up correctly in a WordPress theme, or post to a certain page. A lot of modern themes and plugins use categories to place posts uniquely.

Category issues on WordPress

Unfortunately when using categories like so, they still show up on the blog or website in question. Because these extra categories end up being indexed, it leads to a very fragmented category listing. It also leads to unwanted categories displaying directly on the WordPress blog or website.

How to delete categories on WordPress

You can delete categories in two separate ways. The first involves blocking the category in question from indexing on the site, so basically it still exists as far as the theme is concerned, but is invisible visually. The second method involves actually deleting the related category from the WordPress blog or site template.

3 Steps to delete categories on WordPress

  1. Go WordPress Dashboard
  2. Hover to left sidebar, find Posts > Categories
  3. Go To Category > Remove

Alternative Ways to Delete Categories On WordPress

Use The Robots

Most people are probably reading this and wondering, “what robots”?

What a lot of those people don’t know, is that the WordPress installation actually has a file called Robots.txt that handles the related site’s meta data, sitemaps and search engine related information. It also includes information about the internal links, including what we’re looking for- the categories.

The method to blocking categories in the Robots.txt file is quite simple and straightforward, however it only stops search engines from indexing the category in question. This means that the category will be blocked on the site, but will still appear in SERP if there are ANY existing links.

Look for the following code lines in the Robots.txt file:

The above code lines may or may not have additional commands attached depending on individual theme or WordPress settings.

Just add in the proper commands to the above code so it reflects the following:

If you use this method to block your categories through the Robots.txt file you also have to block indexing using the following tag in the header section of the related pages. So basically, any pages that display the blocked category need to be given the following code in the header tag:

Obviously the head tags should not be included if copying the above code directly, the header tags are just to show where the related code should be placed.

Method 2: Making the Categories Invisible

The next method is also quite simple and just involves injecting code into the proper location so that the category in question can be visually hidden.

Categories can show up in many locations like a blog sidebar, navigation panel or home page. Each location where a category shows up needs to be altered with related code in order to be completely hidden from view.

Before doing anything we need to find the cat_ID or the category ID of the category we want blocked. To do this, simply navigate to the categories menu option, under the posts tab, in the WordPress dashboard panel. Then simply hover the mouse over the category you want blocked, and a URL will appear in the bottom left section of the window.

The category ID is the number listed after category&tag_ID in the URL that appears.

Navigation Menu Categories

Important navigation menu commands, and the actual navigation menu itself, for any WordPress enabled blog or site is located in the Header.php file.

To remove a category from the WordPress blog or site’s navigation menu simply enter the following code within the proper section of the Header.php file.

Make sure to replace the cat_ID tag in the code segment above with the related ID number for the category you want to hide on your blog.

Sidebar Categories

To hide code from the WordPress blog or site’s sidebar panel we will inject pretty much the same code as above but this time within the Sidebar.php file.

Keep in mind that this code segment will not work if the category is being displayed through a WordPress widget. If a widget is being used, you will have to individually edit the code in the widget to hide the category. This does work however if the categories are designed to natively display through the active WordPress theme.

The following code must be added to the category code within the Sidebar.php WordPress theme file:

Main Page Categories

To prevent any categories from displaying on the main page of the WordPress enabled blog or website we simply need to replace existing code of the page in question.

Note: In order to do this edit we need proper admin access to the blog or website, because it involves editing important source and installation files.

Look for the following code:

And replace the above code with the following (make sure to replace cat_ID with the proper ID of the category you want removed):

NOTE: It is important with all of the above methods that you don’t just copy paste the related code, make sure to add it to existing code so that the final tags are extended.

For example here is a bit of finished code that has been extended with the above commands:

In the case above, the related category section is now set to automatically be sorted by name, and will exclude the category with the ID number of “108”.

What happens with my posts when I delete a category?

If you have currently existing posts under your category and you deleted it, the blog posts will be automatically assigned to your default category.

Will I delete posts if I delete a category?

No. Your blog posts won’t be removed from your website but they will be automatically reassigned to your default category.

How do I know what is my default category?

Your default category on WordPress is the one that you cannot delete from the system.

Categories Successfully Deleted

No matter what method you decided to use, those pesky categories should now be completely blocked from displaying on your WordPress blog or website. There are additional areas on a site where categories can appear, so if you don’t see your location listed here check out the source for additional information.

Source: Spanish SEO- Blocking and Excluding Categories in WordPress

Ani Hoang
Ani Hoang

Ani has been managing WordPress websites and optimizing different affiliate sites. She is also passionate about digital marketing and branding. She joined WPHub to plan and execute the backend operations to support your experience on our site.

FREE EBOOK: How to Build a Wordpress Website


As a complete beginner!

FREE EBOOK: The Ultimate Guide To Speed Up Your Website and Increase Conversions!


Site Speed Secretsis a is a step-by-step blueprint about how to speed up your website and increase conversions.