Remove Custom Post Type & Taxonomy Slug From URLs

When it comes to content organization, the custom post types and taxonomies are really useful. The problem is that WordPress automatically adds a rewrite slug to their permalinks.

This might be restricting if you need full control over your permalinks structure or want more readable URLs. In this case, you should consider removing the rewrite slugs. In the following article, you will learn why WordPress includes them and how to fix this problem.

Using a plugin like Permalink Manager is one of the most straightforward ways to remove them from custom post type and taxonomy permalinks.

Pretty permalinks

Custom Post Types' and Taxonomies' Default Permalinks

Post types are different single content items that can be created in WordPress. They include posts, pages, and custom post types like products.

On the other hand, taxonomies let you group items from different post types. WordPress includes two default taxonomies: categories and tags. However, if needed you can also declare additional ones.

In other words, post types are used for individual posts, whereas taxonomies are used to combine them together.

When you set up custom content types, you can customize their permalinks to some extent. While you do not have complete control over default permalinks, you can rename the permalink base by altering the "rewrite" parameter.

So, how do their default permalinks look like? The rewrite slug is included in the permalinks of custom content types and taxonomies so that WordPress can correctly recognize them.

By default, it will generate permalinks with the post type name as the slug. For a custom post type named "portfolio", the URL for a single item should look like this:

http://www.example.com/portfolio/acme-north-america

Similarly, if you had a custom taxonomy named "services", the URL for a single term will look like this:

http://www.example.com/services/automatic-backup

You can absolutely use a different slug for each custom post type, but it must be unique for each post type and taxonomy. The 'slug' key in the 'rewrite' argument allows you adjust the base slug used in the permalink structure for that specific post type.

However, if you want to remove that slug or duplicate it for other content types, you will need a tailored solution, such as Permalink Manager.

Why Remove Custom Post Type and Taxonomy Slugs From WordPress URLs?

Google recommends organizing content URLs so that viewers can easily understand them. You can achieve this by eliminating custom post type and taxonomy slugs from WordPress URLs.

The rewrite slugs lengthen your permalinks, making them harder for users to remember and search engines to understand. However, please keep in mind that changing your present URLs may have an impact on your website's SEO as well as any existing backlinks. Before making any modifications, evaluate your website's SEO performance.

Keep an eye on how your modifications are affecting your visitors and SEO. Also, to keep as much traffic as possible, redirect old URLs to new ones.

How to Remove Custom Post Type and Taxonomy Slugs?

If you have experience with the WordPress API, there are ways to remove it programmatically. Permalink Manager is an out-of-box solution that lets you do what you need to do without any extra skills. It allows you to remove custom post type and taxonomy slugs from your WordPress URLs with a few clicks.

Take a look at the URL examples below to get a better grasp of what the plugin offers. Each example represents a default URL used by WordPress before Permalink Manager was activated, and each contains an obsolete rewrite slug (highlighted in red).

http://example.com/portfolio-item/acme-north-america
http://example.com/product/sample-t-shirt
http://example.com/product-category/apparel/t-shirts

In a nutshell, the plugin offers a hassle-free solution for eliminating rewrite slugs/bases, as demonstrated below. You can accomplish this in two ways, both of which are outlined below.

http://example.com/sample-t-shirt
http://example.com/apparel/t-shirts
http://example.com/acme-north-america

The most convenient method is to use Permastructures. This allows you to automatically delete the post type and taxonomy slugs from new posts and terms. Using the "Regenerate/reset" function, you can also apply the new, correct URL format to all previously published content.

However, if you only want to change a few permalinks, you can also use the custom permalink editor to overwrite the existing ones.

While these examples focus on WooCommerce content types, the instructions may also be applied to other custom post types and taxonomies.

The first step is to modify the Permastructure settings. You may find them under the "Tools -> Permalink Manager -> Permastructures" admin section.

Each post type and taxonomy can have a different permalink format, as seen below. Simply delete the original bases (highlighted in red) from the input fields to get rid of them.

After you save them, the obsolete slug you removed will no longer appear in the permalinks whenever you publish a new post/term.

Original permastructure settings with obsolete rewrite bases
Original permastructure settings with obsolete rewrite bases.
New pretty permalinks structure.
New permastructure settings after the permalink bases were removed from "Portfolio items" & "Portfolio Categories".

How Can I Update Already Created Permalinks?

If you wish to apply new customized formats to previously existing WordPress URLs, you must regenerate them using the "Regenerate/reset" tool. You may skip this step if you did not previously add any posts or terms.

Regenerate/reset section

Manually removing the slugs from each of your unique permalinks is also an option. This approach may take a lot longer than the first, but it gives you more flexibility.

How to edit single permalinks? (URI Editor)
Please read this article to learn more about URI Editor and the procedure of modifying individual permalinks.
The sample portfolio permalink in URI Editor
Essentially, the individual permalink may be entirely customized in any manner you like.
The sample customized pretty permalink in URI Editor
Now, the new pretty permalinks no longer include the original rewrite base.
Go up