Custom Post Type Slug clash Custom Post Type Slug clash wordpress wordpress

Custom Post Type Slug clash


Unfortunately WordPress isn't really designed this way. Part of why this doesn't work for 2 Posts/CPTs even in separate categories, is what happens when one is in both categories? You'd have to start getting some nasty rewrite rules and the redirect_canonical() function involved - at which point you're just asking for 404 errors out the wazoo.

Luckily, instead of relying on taxonomies and CPTs with the same slug, there is something you could do. You could instead drop the taxonomy part of it and use the hierarchical format of your custom post type.

Part of why this works is because you can't assign multiple parents to one post/CPT, so there are no permastruct clashes.

Create a new "Work" called Client 1 and a second called Client 2.

Now, with those "parent works" created, you can create a third "Work" called Cool Project and set the Parent to Client 1, and then create fourth called Cool Project as well and set the parent to Client 2.

This will give you the following permalink structure:

https://example.com/work/client-1/cool-projecthttps://example.com/work/client-2/cool-project

You can see this in action right now here:

These are set up exactly the way I mentioned:

The downside of this is, is that if you use the /work/client-name page to display anything, you'll now have to set up a Post Type Template (Available since WP 4.7.0) to achieve the functionality that you have with the archive template instead.

However it prevents the need for redirects and rewrite rules.

Here's a screenshot of the permalink structure:Here's a screenshot of the permalink structure

Here's a screenshot of the CPT Overview admin page:Here's a screenshot of the CPT Overview admin page