I want to be able to create a custom taxonomy (e.g. 'manufacturers') and custom post type (e.g. 'products') and have the taxonomy title (instead of the slug) used in the post type permalink.
By default this shows the post type as the slug: /products/blue-widget/
But instead I want it to be: /best-widget-co/blue-widget/ (Where 'best-widget-co' is a manufacturers taxonomy value).
I tried setting the taxonomy in the post type Rewrite option as "/%manufacturer%" which outputs:
/%manufacturer%/blue-widget/
I then followed a guide on translating the custom taxonomy (hidden link) which rewrites the URL correctly as: /best-widget-co/blue-widget/ but when trying to access that page I get a 404.
Can you explain where I'm going wrong please?
That is not possible with Custom Posts and taxonomies.
This is a WordPress restriction.
What you can do is not as dynamic, but it is the only what you can do with Custom Data:
- head to Toolset > Post Types > your_post_type > Edit > Options > Rewrite.
Here you can use hard coded strings. Not dynamic placeholders as %%term%%. Only hard coded strings. And those will be prepended to the actual Post Slug.
The same you can do in Taxonomies.
There, you can replace the Taxonomy Slug with another, hard coded (not dynamic) string.
Hi Beda,
Thanks for the response. I was sure I'd seen a solution to this in the past so I've been doing some further research and it seems I was on the right track before but my implementation was slightly out.
You're right that the URL can't be fully dynamic (and everyone else seems to have the same advice) but if I prepend the CPT slug to the CPT's rewrite rule: products/%manufacturer% then this seems to work and will hopefully be an acceptable solution to my end client.
FYI the "solution" to this had previously been posted on the Toolset support forum at: https://toolset.com/forums/topic/custom-taxonomies-not-showing-on-permalink/#post-16949
Thanks again!