WordPress has a simple and effective built-in permalinks system. It does have certain disadvantages, though. One of them is that you cannot use the same permalink structure for multiple content types.
Although most users find the inbuilt WordPress permalink system to be adequate, it might become a problem if you need more customization options. This becomes especially clear when you try to incorporate the silo architecture into your permalink structure.
Thankfully, you have a few choices if you want to build a more unified permalink structure for your website. You can overcome this limitation by using custom code snippets. However, you will need to have some knowledge with WordPress code.
Another easier alternative is to use a plugin such as Permalink Manager. In this tutorial, you will learn how to use it to duplicate permalink formats without any coding knowledge.
How to Duplicate Permalink Formats in Permalink Manager?
To cut a long tale short, the plugin allows you to set the same rewrite base/slug for different content types since it does not use rewrite rules (regular expressions) to detect the content. To be specific, it identifies posts and terms based on their complete custom permalinks rather than their slugs. The plugin can easily detect them as long as you keep the permalinks unique as a whole.
A Practical Case Study
Below is a basic case study, but you may take it as an example and mimic it in any more sophisticated permalink structure.
Looking at the list below, you will observe that we have three different content types, each with a slightly different URL format. For each content type, the rewrite slug ("car", "manufacturer", "transmission") parameter is unique. This is required since otherwise the built-in permalink functions will be unable to identify the content.
Initial permalinks:
Car (custom post type):
http://example.com/cars/fiesta-2015Manufacturer (custom taxonomy):
http://example.com/manufacturer/fordTransmission (custom taxonomy):
http://example.com/transmission/automatic
Because Permalink Manager does not rely on rewrite rules, you can change the URL formats in any way you choose. In this situation, you can use this option to force all content types to use the same permalink base ("cars").
New custom permalinks:
Car (custom post type):
http://example.com/cars/ford/fiesta-2015Manufacturer (custom taxonomy):
http://example.com/cars/fordTransmission (custom taxonomy):
http://example.com/cars/automatic
Instructions
Now that you know there is a way to duplicate permalink base, it is time to explain how to achieve it. The first step is to change the permastructure settings.
To do so, go to the admin section "Tools -> Permalink Manager -> Permastructures". Once you have opened it, find all of the content types whose permalink base you want to alter.
This should be straightforward. All you have to do is replace the words "transmission" and "manufacturer" with the word "cars".
Original permastructure settings:
Car (custom post type):
http://example.com/cars/%car%Manufacturer (custom taxonomy):
http://example.com/manufacturer/%manufacturer%Transmission (custom taxonomy):
http://example.com/transmission/%transmission%
New permastructure settings:
Car (custom post type):
http://example.com/cars/%car%Manufacturer (custom taxonomy):
http://example.com/cars/%manufacturer%Transmission (custom taxonomy):
http://example.com/cars/%transmission%
Please remember to save your changes after adjusting the settings by clicking the "Save Permastructures" button at the bottom. Now, when you add a new "car" item, "transmission" or "manufacturer" term in the future, Permalink Manager will adhere to the format you set.
Why Does the WordPress Permalink System Need Unique Rewrite Bases?
Everything below applies exclusively to the built-in permalink system. Above, you can find instructions for using an extra plugin to get around this limitation.
The concept of permalink bases and rewrite rules can be confusing at first glance. In WordPress, rewrite bases are predefined slugs that are used to identify the type of content being requested based on the URL address. This helps to reduce the number of database requests, improving the performance of your website.
If the permalink rewrite bases are not unique for each custom post type and taxonomy, WordPress may be unable to accurately detect the URL and may return a "not found" error.
One issue that emerges here is that certain rewrite rules (permalink formats) take precedence over others. Furthermore, when WordPress reads the URL, it does not care whether the post, page, or term exists; it simply has to match the permalink format with possibly the greatest priority. The rewrite base, which is the first fragment of the URL after the domain name, plays a crucial role in this process.
"Product category" permalinks (WordPress detects them correctly)
http://example.com/shop/clothing
http://example.com/shop/clothing/men
http://example.com/shop/clothing/women
"Product" permalinks (WordPress sees them as product categories and returns 404)
http://example.com/shop/amazing-plain-t-shirt
http://example.com/shop/beautiful-white-cotton-dress
Take a look at the example above. If you use the same rewrite slug (shop) for both products and product categories permalinks, WordPress will treat any URLs starting with "/shop/" as product category permalinks.
As a result, whenever a visitor accesses any product page, WordPress will attempt to load a product-category page that does not exist.