Add category to custom post type permalinks

Do you need to add category to custom post type? The most well-known shortcoming of the WordPress content management system is probably the lack of flexibility in terms of editing permalinks. One example of this limitation is the inability to add taxonomy slugs to custom post type items’ permalinks.

There are a large number of discussions on StackOverflow where users are seeking for a solution to this particular issue. It is possible to further personalize them by adding more rewrite rules and complicated PHP code snippets, if you are familiar with the WordPress API. However, this will need more time and work. The majority of WordPress users, however, will find this to be an inconvenient solution to their problem.

How to add custom taxonomy in custom post type permalink?

Permalink Manager, on the other hand, allows you to quickly and easily add category to custom post type permalinks. The biggest benefit of using the plugin is that it does not need any programming knowledge on your part.

The URL examples provided below have been purposefully simplified in order to give you a better understanding of how this feature works.

Original WordPress permalinks (custom post type items)

New permalinks item customized with Permalink Manager (custom post type items with tax slugs included)

Versatility of Permalink Manager
There are many ways to enhance the structure of your WordPress permalinks. You have the option to keep the permalink basis (“product” and “vehicle” highlighted in red in the example below), delete it totally, or change the permalink structure to something completely different. You may also use the same permalink basis for multiple content types or add custom fields to them.

The procedure is straightforward, and you should have no difficulty completing it. If you want to include custom taxonomy slugs in your WordPress permalinks, you’ll need to go to the Permalink Manager section (“Tools -> Permalink Manager -> Permastructures“).

Permastructures section where you can add category to custom post type permalinks
The initial permastructure settings.

Now, scroll down to the bottom of the page until you find the custom post type that you want to adjust. In this simple example, we are adding two taxonomies to the permalinks for the “Cars” post type (“Manufacturer” and “Fuel“).

How to edit Cars permalinks?
You may change the settings for each post type independently.
The custom field permastructure tags should be structured as follows: %custom_taxonomy_name%.

After that, you should insert the tags into the permastructure. The names of custom taxonomies are also the permastructure tags. If necessary, you may locate all of the possible permastructure tags in the “Permastructure tags” section.

New permastructure settings for custom post type
For the sake of this example, we shall use the %manufacturer% and %fuel%. The tags will vary depending on your specific case.
New permalink formats and existing permalinks
The taxonomy slugs will be automatically incorporated in all new post URLs. Existing URLs will need to be regenerated if you want to use the new formats on them too. You will find step-by-by-step instructions on how to do this in this post.
A sample post permalink with category slug included
Both Manufacturer & Fuel terms’ slugs are now present in single Car permalink.

How to delete parents from included hierarchical taxonomy slug?

Generally, WordPress lets you to register two types of taxonomies: hierarchical and nonhierarchical. The first one allows you have parent and child terms, same as with inbuilt categories. For example, you may have a custom taxonomy named “countries” and add parent term named “Europe” with child terms such as “Germany“, “France“, and “Italy“. The second type (nonhierarchical) will function identically to post tags. Using Permalink Manager, you may add both hierarchical and non-hierarchical taxonomies to post permalinks.

Slugs hierarchy
With SEO in mind, there are several cases when it may be preferable to keep the URLs of custom post type items as short as possible. Of course, you may configure Permalink Manager to automatically delete the parents’ slugs from child permalinks.

You can find more detailed information about this functionality in this article.

Go up