WordPress automatically adds category slug “/category/” to the URLs of category archive pages. For example, if you have a category called News, the default URL will be:
https://example.com/category/news/
Many website owners prefer a cleaner URL structure, like:
https://example.com/news/
Removing the category slug improves readability, enhances SEO, and makes URLs more user-friendly. In this article, we will explore different methods to achieve this.
Method 1: Using Code (Functions.php or WP Code Snippet Plugin) for Remove Category Slug
You can remove the category base manually by adding a small PHP snippet to your theme’s functions.php
file or by using the WP Code Plugin. Follow these steps:
Step 1: Add the Code to Functions.php
- Go to your WordPress Dashboard → Appearance → Theme File Editor.
- Open the
functions.php
file of your child theme (if you don’t have a child theme, consider using the WP Code plugin instead). - Add the following code snippet at the bottom of the file:
function custom_remove_category_base($category_link) { $category_link = str_replace('/category/', '/', $category_link); return $category_link; } add_filter('category_link', 'custom_remove_category_base');
4. Click Update File and save the changes.
Step 2: Flush Permalinks
After adding the code, you must refresh the permalink structure:
- Go to Settings → Permalinks in your WordPress dashboard.
- Click Save Changes (without making any modifications).
- Now, check your category URLs. The slug “/category/” should be removed.
Method 2: Using a Plugin (Easy & Recommended) for Remove Category Slug
If you’re not comfortable editing theme files, you can use a plugin. Some recommended plugins for removing the category slug are:
✅ Remove Category URL
✅ Yoast SEO (Premium Feature)
✅ Permalink Manager Lite
Using “Remove Category URL” Plugin
- Install and activate the Remove Category URL plugin.
- Go to Settings → Permalinks and check if the category slug is removed.
- Flush the permalinks by clicking Save Changes.
This method is the easiest and requires no coding knowledge.
Method 3: Using .htaccess (Advanced Users Only) for Remove Category Slug
If the above methods don’t work, you can manually rewrite the URLs using .htaccess
.
- Open your .htaccess file (located in your WordPress root directory).
- Add this code at the end:
RewriteRule ^category/(.+)$ https://example.com/$1 [R=301,L]
- Save the file and refresh your website.
Warning: Editing .htaccess
incorrectly can break your site. Always back up before making changes.
Troubleshooting Common Issues
- 404 Errors After Removing the Slug?
- Go to Settings → Permalinks and click Save Changes to flush the permalinks.
- Changes Not Visible?
- Clear your browser cache or try opening your site in an incognito window.
- If using a caching plugin (WP Rocket, W3 Total Cache), clear the cache.
- Conflicts with Other Plugins?
- Some SEO and permalink plugins may override custom settings. Try disabling them to test if they interfere.