In this article we will show you Remove a Category from My WordPress URL
As I am sure that you know, WordPress is a CMS (Content Management System). WordPress is used to create and publish articles and media for blogs and websites. It has become an incredibly popular platform with millions of users. As of Spring 2021, it has been calculated that more than 40% of the top ten million websites are built on WordPress. Now that is incredible market penetration.
One of the features of WordPress is that it has the option of adding various categories to a website. Each category is allocated a “category page” and a separate RSS feed. You can view any posts that are allocated to a category by visiting the category page for that topic.
Out of the box, WordPress will add “category” as the standard prefix for all of the category pages. This makes it clear that they are categories and not posts/pages.
For example, if you had a motoring website and one of the categories was “Trucks”, then the URL for that category would be http://motoring.com/category/trucks/.
Typically, there is no need to remove the prefix “category” as it is a useful way of explaining how your website is organized. That said, there are times when you may prefer to remove the prefix from the URL, and this is what we will discuss in this article.
Reasons to Remove Category from WordPress URL
Generally speaking, it is a bad idea to remove the category prefix from your WordPress website, as it not only assists users to understand your website structure, but it also provides pointers to search engines. So only remove this prefix if there is a particularly good reason, such as the following.
SEO Reasons
As a webmaster, your target has to be to produce an SEO friendly URL, which only contains optimized keywords. These keywords should be easy to understand by both humans and search engines. It may be that the category can detract from this target.
Let’s go back to our example website on motoring. By default, an article in the category trucks would have the following URL:
http://motoring.com/category/trucks/
If we were to remove the category prefix, the WordPress URL would look like this:
This is clearly more focused and will produce better SEO results. However, we should also point out that there may be disadvantages to removing the category prefix.
- A problem can occur if they have a category and a page with the same name. This can cause an infinite redirection loop and the page will be unable to load.
- If you are using %postname% as your WordPress URL structure, and you have a category of the same name as the post, this can also produce the same infinite loop scenario.
Personalizing a Category Prefix
When creating a website, the term category may not be ideal for describing groups of posts. Say, for example, you have a website that is posting news items, you may feel that using the term “Articles” would be more appropriate than using the term “Categories”. In cases such as this, you may want to charge the base prefix.
An associated issue is when you are happy to have a category prefix, but you would prefer another term than” Category.”
It is quite possible to change the term “category’ to any other one of your choosing. This may be, for example, “Article”,” Topic”, or something more specific to your website, such as “Tutorials.”
In our example from above, the edited WordPress URL when using “articles” would be:
http://motoring.com/articles/trucks/
You can make modifications to the term “categories” in the WordPress Dashboard Settings section.
Settings >> Permalinks >> Optional >> Category base
Change the term to the one you wish to use and then press “Save.”
Changing Your WordPress Permalinks Settings
What is a Permalink?
A permalink is the section of a web address that follows the domain name. When your permalinks are being used correctly, they fulfil certain functions:
- They allow the website visitor to get an indication of what the page is about from the words used in the permalink.
- They assist search engines in finding pages related to a topic.
- They also provide a permanent address that can be remembered by the visitor, so a later return is possible.
What is the Default Setting?
When WordPress is set up, it sets the permalinks by default to “day + name.” As soon as you have completed the installation of WordPress it is important to reset the selection to the one that is most appropriate to your needs. Many people find that choosing “Post name” offers the best results as it makes it very clear what the page or post is about.
Changing the Permalink Structure when you are installing WordPress, It is just a matter of making your selection before you start adding posts or pages. It really is simple. Using the WordPress dashboard go to Settings >> Permalinks and make your selection then save it.
Clearly, It is really a lot better to make changes to this setting BEFORE you start adding Pages and Posts to a WordPress website. Whilst you can change this at a later stage, doing so has the potential to break your website. So, think carefully about how you want URLs to look at the planning stage of the site, immediately after you have installed WordPress.
Editing the permalink settings on the website, after it is published, is a major change to the site and should only be done after a great deal of thought.
Every page or post on your website has a URL that is unique and has been permanently assigned. What the URL looks like depends on the “Permalink Settings” in the WordPress dashboard. Editing this setting can produce the following issues:
- Search Rankings
- Outdated links from external websites.
- Broken internal links on your own website.
Removing the Category
METHOD 1 - Remove Category in WordPress Permalinks
Using this method, it is possible to remove the category prefix completely. This is done by making changes to the WordPress permanent link. This method involves five steps and is easy to do:
- Go to the WordPress Dashboard.
- Select Settings >> Permalinks.
- Go to “Custom Structure” and enter “/%category%/%postname%/.”
- Go down the page to category base and enter a full stop.
- Save the changes that have been made.
METHOD 2 - Adding code in the "functions.php" file to Remove the Category.
This second way to remove the category is a little more complex and beginners may find it intimidating. This option cannot work if you have already removed the word “category” from your WordPress URL or slug
Do not do this if you feel concerned about entering code.
- Start at your WordPress Dashboard.
- Choose Appearance >> Theme Editor.
- Find the file named “functions.php” and open it.
- Left Click just before the last PHP tag.
- Copy the following excerpt of code –
“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);”
- Right click and select “Paste”.
- Save the changes made and close the windows.
METHOD 3 - Plugins
There are two plugins that can be used to remove the category from the URL. You will first need to install the plugin of your choice and then follow the instructions below.
Yoast SEO Plugin
Yoast SEO plugin has several options. One of them is to remove the category prefix. This method does not require editing or adding new code to files, so may be easier for some users. Once again, you must not have changed the Category base in the Permalinks section.
Procedure
- Start at the WordPress Dashboard
- Select Yoast SEO >> Search Appearance >> Taxonomies.
- Go to Category URLs and choose “Remove the category prefix.”
- Save the changes.
Remove Category URL Plugin
As the name suggests, the plugin is designed for the specific purpose of removing the category prefix. It does not require any setting-up and as a bonus, it will also redirect any old permalinks to the updated choice.
Procedure
- Go to your WordPress dashboard.
- Install the plugin.
- Activate the plugin.
- Once activated it’s done, nothing more to do.
How Do I Automatically Redirect People from My Old Category Permalink?
The best solution for this problem is to use the Redirection plugin, adding both your old and new category links.
How to Remove a Category from My WordPress URL Final Thoughts
We have given you a selection of choices for methods to remove and amend the Category prefix. Some methods are easier than others and you should select the method that is most appropriate for your level of skill and for the results you want to achieve.
Think carefully about how any change will reflect on your SEO results and whether it will cause broken links from external sites.
WordPress is an excellent tool for creating websites and understand all of the features completely makes a lot of sense Understanding when and how to make changes to the Permalinks setup is particularly important and can have an impact on the performance of your website.
We hope that this article has been useful.
Additional articles that might be of interest.