WordPress has two options to categorize blog content: tags and categories. Categories are broad and can have subcategories. If you use them in WordPress, your users can easily find the content they are looking for.
In this article, we try to teach you how to include category in WordPress permalinks, as well as adding subcategories to them.
Including Category to SEO Friendly URLs in WordPress
The default structure of the WordPress permalinks doesn’t display categories and subcategories in a post URL.
If you use categories and subcategories in permalinks, you allow users to identify and locate their favorite content. In addition, if you have breadcrumbs activated in posts, using categories and subcategories are very beneficial.
Also, the post’s URL may include more keywords which will have a positive effect on the SEO.
Adding Category and Subcategory in WordPress Post URLs
First, log-in to WordPress dashboard. Then, go on Settings and Permalinks. In the general configuration, change the post URL structure and type in:
/%category%/%postname%/
Finally, save your changes.
Keep in mind, if you don’t have any categories yet, once you save these changes, all of your posts will display the WordPress default category in their URL.
Therefore, create new categories and add your posts to the related category to avoid confusion.
WordPress permalinks like /category/subcategory/post (Including category and child category in URL)
To show WordPress permalinks as category/subcategory/post go to Settings > Permalinks.
Choose ‘Custom Structure‘ and add /%category%/%postname%/ to the field.
Now if you add one category and one subcategory, WordPress will show both of them in the permalink.
If there is more than one category or subcategory, WordPress will show the primary category or just show them based on alphabetical order.
How to remove category from WordPress permalink
If by default, categories are displayed in the URL, there a few ways to remove them.
Remove categories from WordPress permalinks through setting
1. In the WordPress dashboard, go to Settings and then Permalinks.
2. Choose the structure and type:
/%category%/%postname%/
3. Add a dot in front of the paragraph and save the changes.
Make sure you follow these steps, otherwise, WordPress uses the default amount in this field. Check your website’s URL. Currently, this method is still viable but there are no guarantees that this work in the future.
Remove categories from permalink using the .htaccess file
By adding the code below to the .htaccess file, you can remove categories from WordPress permalinks.
RewriteRule ^category/(.+)$ http://www.yourwebsite.com/$1 [R=301,L]
Make sure you add the code before the </IfModule> tag in the .htaccess file.
Remove categories from permalink using Yoast SEO
The latest Yoast SEO update disabled the ability to remove categories from permalinks. However, if you are not using the latest version, you may still use this plugin to remove categories from permalinks.
Some websites are still able to delete categories from WordPress permalinks with the latest version of Yoast SEO.
Keep in mind, if you have updated the plugin and cannot remove categories from the WordPress permalinks, you may have to install other plugins that are designed for this.
Remove categories from permalinks using a plugin
These plugins are very popular and useful. If your WordPress website is older than 6 months, you could use the Remove Category URL plugin.
These plugins work automatically and you don’t need to configure them nor edit a file.
Another recommended plugin is FV Top Level Categories. Writing code is also another way, although, it may affect the performance of your website.
Conclusion
In this article, we discussed how to include a category in WordPress and how to remove category from the WordPress permalinks. Categories in permalink can improve your website’s SEO, increase the coming traffic and sort your content.