How To Remove the Category From the WordPress URL
parallax background

How To Remove the Category From the WordPress URL

How To Fix The WordPress Parse Error Easily
February 13, 2021
Awesome Websites with an Orange Color Palette (48 Examples)
April 19, 2021
How To Fix The WordPress Parse Error Easily
February 13, 2021
Awesome Websites with an Orange Color Palette (48 Examples)
April 19, 2021
 

You have probably noticed that WordPress automatically includes the category prefix in the URL slug of your site. Each category has its own archive page, so this feature keeps the content well organized.

Usually, the prefix doesn't need to be removed. It helps visitors understand the structure of your page.

However, sometimes it can be beneficial to remove a category from a WordPress URL. This article explores some valid reasons for taking the prefix out. You’ll also learn how to do it.

Reasons to Remove Category From WordPress URL

 

The category prefix is part of the URL slug. As any SEO-conscious website developer or owner, your goal is to optimize this feature.

What exactly does URL slug refer to? It is the part of your address that comes right after the domain name. It identifies the resource, a specific page on your site. The slug tells search engines where to find your web page. Moreover, visitors can understand from the keywords what the page is about.

Slugs are usually generated by default from a page title, but they can be changed manually. Ideally, a clean SEO-friendly URL contains only meaningful and relevant keywords. They should be intuitive and easy to understand by both search engines and visitors. However, that's not the only relevant thing when it comes to the SEO of your website, as the speed of the website, UX and the importance of good link building, which can be assessed using a backlink audit checker, is also necessary.

That's the reason why some developers may decide to remove the category prefix from the URL.

Let's have a look at an example of what it could look like if you remove a category from a WordPress URL:

If the original slug was ‘yoursite.com/category/best-seo-practices’, the modified slug would be ‘yoursite.com/best-seo-practices’.

The link in the example above now looks cleaner while it still includes the keywords which are important for SEO. A visitor who found your page using a search engine will also directly see the content he was looking for.

If you modify the permalinks of your site, make sure you redirect old URLs to your new ones. Otherwise, users visiting the old category page will run into an error.

So far, we’ve explained why you may decide to remove categories and what you should be careful about.

Here are some tips on how to take the prefix out of the URL slug.

Modifying Category Base Prefix

 

Some developers don't mind the length of the URL slug, but they want to personalize it.

In such a case, you can change the Category base. Instead of 'Category', you can customize the prefix to 'Articles', 'Topics', 'Blog', 'Genre', 'Tutorials', or similar.

To demonstrate what the edited slug will look like, we can use the same example mentioned earlier.

If the original slug was ‘yoursite.com/category/best-seo-practices’, the new URL could be ‘yoursite.com/articles/best-seo-practices’.

You can modify the category base prefix if you go to the Settings in your WordPress admin.

  • Go to your admin dashboard.
  • Go to Settings >> Permalinks >> Optional >> Category base.
  • Enter your customized category base (e.g. 'Articles')
  • Save the changes.

By making this modification, you can personalize the category prefix in your WordPress URL. But you may decide to completely remove it.

Remove Category in WordPress Permalinks

 

This is an option that allows you to take out the Category prefix completely by modifying your site's permanent link settings.

Here is the process described step by step:

  • Connect to your WordPress dashboard.
  • Go to Settings >> Permalinks.
  • Go to Custom Structure and put ‘/%category%/%postname%/’.
  • Go to Category Base and type in a dot “. “.
  • Save the changes.

The category prefix was removed by typing the dot in the Category Base field. If the field is left blank, WordPress will use the default prefix.

Removing Category by Adding a Code in functions.php File

 

Another way to remove a category from a WordPress URL is by typing in a code in functions.php.

This option will not work if you have already modified the category base settings and replaced or removed the word 'category' from your URL slug.

In order to add the code, follow this process:

  • Go to your WordPress dashboard.
  • Select Appearance >> Theme Editor.
  • Find ‘functions.php’.
  • Type the following code 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);

Using Yoast's SEO Plugin to Remove Category from WordPress URL

 

Yoast SEO is a search engine optimization plug-in for WordPress. It comes with many useful features.

One of the many functions it offers is the possibility to help you remove the category prefix. So if you're already using this plugin, this may be another easy way to customize your URL look, without adding or changing any code.

Before you use this procedure, make sure that you haven't modified the Category Base settings in permalinks.

Follow the steps below to take the category prefix out:

  • Go to your WordPress dashboard.
  • Select Yoast SEO >> Search Appearance>> Taxonomies
  • Go to Category URLs and select ‘Remove the categories prefix’.
  • Save the changes.

Modifying .htaccess to Remove Category From WordPress URL

I'm interrupting the article to tell you about BeTheme, the definitive multipurpose theme. If trying to satisfy multiple clients has become more stressful than rewarding, BeTheme has a solution for that.

BeTheme’s selection of hundreds of customizable, responsive pre-built websites is the highlight and a proven stress reducer.

The customizability of the theme makes it a dream come true for its users. There are 4 types of Page Builders that you can use with it: WPBakery, BeBuilder, and Elementor among them.

And now with the Live Builder, it’s even more impressive.

Check out BeTheme and see why our users love it!

The rest of the article is down below.

 

Besides using a plugin or any of the other options mentioned earlier, you can also remove the category prefix by adding a code to your .htaccess file.

You can access the file either via FTP or cPanel. If you can't find the .htaccess file, check if your file manager is set up to show hidden files (dotfiles).

Here are the instructions:

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

Using the Remove Category URL Plugin

 

The next option you have when trying to modify your URL slug is the Remove Category URL plugin.

This plugin completely removes the category prefix. It's easy to use and doesn't require any configuration. It also redirects old category permalinks to the new ones.

However, before installing more plugins, try another method first. Some plugins can negatively affect the loading speed of your site.

If you decide to install this tool, these are the steps:

  • Go to your WordPress dashboard.
  • Select Plugins >> Add new
  • Type ‘Remove Category URL’ in the ‘Search plugins’ box.
  • Click on ‘Install now’.
  • After it has been installed, click on ‘Activate’.
 

Another plugin that can assist you with removing the category prefix is FV Top Level Categories. It is simple to use and light on code. It automatically redirects old category permalinks to the new ones.

Ending thoughts on how to remove category from WordPress URL

Each time you create a new category in WordPress, an archive page for that category is automatically generated. The 'category' prefix is by default included in the URL slug.

Although categories add some structure to your content, there are some good reasons to remove the category base.

Trimming the unnecessary wordiness while keeping the important keywords in the URL slug can help the site's SEO.

It also improves the readability of the link and makes it easier for visitors to identify the content they are looking for.

This can be especially beneficial if you're focusing on specific niches and want to emphasize certain keywords or if you're aiming to outsource link building efforts to improve your website's authority.

There are a few effective ways to remove categories. Changing the permalinks is one option.

Plugins can do the job too. If you're already using the Yoast SEO plugin, you can benefit from its many useful features, including the option to remove categories.

There are other plugins too, such as those suggested in this article.

If you feel confident adding a code, you can remove the category prefix in the .htaccess or functions.php file.

Any of the above-mentioned methods will help you achieve the desired customized and SEO friendly look of your URL slug. These steps have been tried and are safe to use.

If you enjoyed reading this article on how to remove category from WordPress URL, you should check out this one about fixing the destination folder already exists.

We also wrote about a few related subjects like
WordPress posting to Facebook,
how to reorder pages in WordPress,
fix the could not save password reset key to database,
failed to load resource,
fixing the another update is currently in progress,
how to revert WordPress to previous version and
how to add a button in WordPress.

Albert Ślusarczyk
Albert Ślusarczyk
As the co-creator of Be Theme, I am a strong believer in designing with care and patience. I pour my energy, time & knowledge into perfecting the theme for our 260,000+ customers.