How to Remove Category from URL in WordPress

You may have seen WordPress automatically add the category prefix to your site’s URL slug. Because each category has its archive page, the information is well-organized.

Typically, the prefix does not need removal. Instead, it helps visitors grasp the page’s structure. Nevertheless, deleting a category from a WordPress URL might occasionally be advantageous. 

This article will show you how to remove category from URL in WordPress. So, without further ado, let’s get started.

Why does WordPress Add A Category to the URL?

In WordPress, your theme has a file named “Archive.php” that organizes a list of posts by post type, category, tags, etc. With these archive pages created by Archive.php, the URL of the post or page is linked to the category.

Reasons to Remove Category From WordPress URL

In short: When the word “category” is part of a website’s URL, it’s easier for site visitors to know that the page they’re looking at is a category of something. However, this may make the URL longer. 

The category prefix is included inside the URL slug. The objective of every website developer or owner is to maximize this function.

What does URL slug specifically relate to? It is the part of your web address that follows the domain name. It identifies the resource, which is a particular page on your website. The slug directs search engines to your website’s page. Moreover, viewers might deduce the page’s topic from the keywords.

Slugs are often created automatically based on a page’s title, although they may be modified manually. An ideal SEO-friendly URL comprises only relevant and significant keywords. They should be simple to comprehend for both search engines and visitors.

Because of this, some developers may want to remove the category prefix from the URL.

Let’s see an example of what a WordPress URL may look like if a category is removed:

For example, if the original slug was ‘example.com/category/test-example,’ the modified slug would be ‘example.com/test-example.’

The link in the example above is now more aesthetically pleasing while retaining the SEO-relevant keywords. In addition, a visitor who discovered your page via a search engine will also view the desired material.

If you adjust your site’s permalinks, you must redirect old URLs to the new ones. Otherwise, visitors to the previous category page would get an error.

You now know why and what to watch out for when deciding whether or not to eliminate categories.

As, you know SEO is very important for a website, we have made a detailed post about WordPress SEO and the things you should know about it.

How to Remove Category from URL in WordPress

Although WordPress has a default option for displaying the URL of your category page, you could change it. Or, you can eliminate the category. This is possible through the WordPress dashboard. Therefore, it will just take a few minutes to erase a category from your URL.

Remove Category from URL using WordPress Setting

Here are the instructions to remove category from URL in WordPress.

Removing Category from URL
Removing Category from URL
  • Log in to your WordPress dashboard
  • Go to Setting >> Permalink 
  • Select Post Name
  • Add desired post name.
  • Save the changes.

And, voila! You’re done. You just successfully removed category from URL in WordPress.

Modifying .htaccess to Remove Category from URL

The file may be accessed through FTP or cPanel. If you cannot locate the .htaccess file, ensure that your file manager is configured to display hidden files (dotfiles).

Here’s how to do it:

  • Go to your .htaccess file.
  • Add the following code after the closing tag in the file:
RewriteRule ^category/(.+)$ http://www.example.com/$1 [R=301,L]
  • Write your domain name in place of www.example.com in the code above.
  • Upload it to your server’s public_html directory.

You can also learn about adding a category and subcategory right here!

Remove Category from URL Using Plugins

Another way is, as always, by installing a plugin. Plugins are an excellent way to add or remove functionality from a WordPress website. For example, you can use the popular ones like RankMath or Yoast to remove category from URL very easily. But we don’t recommend that because the more plugins you use, the slower your website will be.

👉🏼Here’s our guide to Setup RankMath!

Conclusion

This article discussed how to remove category from URL in WordPress. We provided three simple and easy methods. Of course, you are free to use any of it. 

The first way is to modify the permalinks in your WordPress settings simply; recommended for beginners. Although for advanced users, we recommend editing the .htaccess file to remove a category from the URL.

If you still have any questions, please comment below. We will be glad to help you out.

Editorial Staff
Editorial Staff

With over 10+ years of experience in the industry, our experts from the editorial panel are a trusted source of knowledge for WordPress solutions. As part of the editorial staff at WPLearners, our experts are dedicated to sharing their expertise and helping you make the most of your WordPress journey.

Leave a Reply