Remove Custom Post Type & Taxonomy Slug From URLs

Custom post types and taxonomies are very useful when it comes to organizing your WordPress website. The problem with them is that WordPress 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

How WordPress Generates Permalinks for Custom Post Types and Taxonomies?

Post types refer to the various groups of content that can be declared in WordPress, including posts, pages, and custom post types. Taxonomies are related to them since they allow you to organize and group post types. In other words, post types are used for individual pieces of content, and taxonomies are used to organize them together in groups.

When you set up custom post types and taxonomies, you can customize their permalinks to some extent. While you do not have complete control over WordPress's inbuilt 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 redundant slugs may make your permalinks longer, more difficult to remember, and more problematic for visitors and search engines to comprehend.

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?

Thankfully, you can quickly remove custom post type and taxonomy slugs from your WordPress URLs with Permalink Manager.

The different content types managed by WooCommerce are shown here, along with sample permalinks. Each example shows the original URL before Permalink Manager was installed, as well as the desired final pretty permalink.

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

The rewrite bases that are indicated in red are the ones we want to get rid of. You may accomplish this in two ways. Both of them have detailed instructions 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.

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