WordPress CMS has many features. One of these features is adding categories to your content. By using categories, you can sort your content. In this article, we discuss how you can remove the category from the WordPress URL.
WordPress has a special structure for its categories. By default, you can see the main category in your WordPress URLs. Below, we discuss how you can change your default category or remove it from your WordPress URLs.
How to Remove the Category From WordPress Permalinks?
By default, if there are any categories, you can see “category” in your domain URL. For example, if you have a category called WordPress, its URL will be displayed as below:
www.yourdomain.com/category/wordpress
If for any reasons you want to change this URL or remove it, you need to follow the steps below:
1. Remove Category from URL
The first method to remove the category from URL is done in WordPress itself. First, you need to log in to your WordPress dashboard. From the menu hover over Settings and then click on Permalinks. In the permalinks click on Custom Structure.
With this option, you can create your desired permalinks for your categories. To remove the category URL type in /%category%/%postname%/ in the right field. Finally, type in a dot in the Category Base section. Make sure you save your changes.
Keep in mind, you shouldn’t leave Category Base blank. Otherwise, the category will be displayed in your WordPress URLs.
2. Remove Category From WordPress URL With a Plugin
Another way to remove the category from WordPress URLs is by installing Remove Category URL plugin. One of the advantages of this plugin compared to other plugins in this genre is its lightness. Remove Category URL is a user-friendly plugin.
This plugin doesn’t have any advanced configurations. After installing the plugin, it starts working immediately. You just need to download, install, and activate it.
Other than Remove Category URL, FV Top Level Categories is another popular plugin to remove the category from WordPress URLs. With this plugin, you can easily remove the category from WordPress URLs.
3. Remove category from WordPress URLs with Yoast SEO
As you know, Yoast SEO is a popular plugin to improve your website’s SEO. Other than SEO features, you can also customize your permalinks with Yoast SEO. In this plugin, you can remove the category from WordPress URLs in only a few minutes. To do so, follow the steps below:
- From your WordPress menu, click on Yoast SEO.
- From the Yoast SEO menu, click on Advance.
- From the opened page click on Permalink.
- Check Strip the category base (usually /category/) from the category URL.
- Save your changes.
4. Remove category from WordPress URLs from .htaccess
Ways we mentioned above are done through plugins and WordPress Settings. However, you can manually remove the category from your WordPress URLs.
To do so, you need to make some changes to your .htaccess file. First, you need to have access to this file. (it doesn’t matter if you access it through cPanel or FTP) You just need to copy and paste the code below to your .htaccess file and save your changes:
RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]
5. Remove category from WordPress URLs using code in functions.php
In this method, you need to make sure you haven’t made any changes to your Category Base settings in permalinks. Because this method looks for the word “category” and if it cannot find it, it won’t work.
First, from your WordPress menu click on Appearance and then Editor. Look for functions.php file then add the code below before the last PHP tag.
function remove_category( $string, $type ) { if ( $type != 'single' && $type == 'category' && ( strpos( $string, 'category' ) !== false ) ) { $url_without_category = str_replace( "/category/", "/", $string ); return trailingslashit( $url_without_category ); } return $string; } add_filter( 'user_trailingslashit', 'remove_category', 100, 2);
Every method we mentioned in this article helps you to remove the category from WordPress URLs. If you don’t have any knowledge of programming we recommend choosing the other methods.
Conclusion
In this article, we discussed how to remove a category from the WordPress URL. The first way is to simply modify the permalinks in your WordPress settings. The second way is as always by installing a plugin.
Plugins are a good way to add or remove functionality from a WordPress website. Also, if you have Yoast SEO plugin installed on your WordPress website, you can remove a category from WordPress URLs easily.
Although for advanced users, we recommend editing the .htaccess file to remove a category from URL.