Skip Navigation

[Resolved] How to use taxonomy term placeholders in CPT url permalinks?

This thread is resolved. Here is a description of the problem and solution.

Problem:
With standard posts the permalinks can use %category% placeholders. Is it possible to do the same with taxonomy terms?

Solution:
Not without custom coding or using 3rd-party plugins.

One such plugin is https://wordpress.org/plugins/custom-post-type-permalinks/

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by coetzeeG 6 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#603334

Hi,

I have 2 taxonomies linked to the post type Listings that would like to use as part of the url structure used on a single ad.

The taxonomies are; Listing categories and Region.

Currently, a single ad url displays like this: hidden link

I would like to see if I can get it to display like this: hidden link, so my final url would be: hidden link

Is something like this possible?

#603420

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

It's not possible without coding a custom solution.

While thinking about a technical solution, it occurred to me that there is a logical problem in any case.

Posts can have multiple taxonomy terms assigned.

It may be that in your particular case you are only assigning a single term to the posts (e.g. only one region), but by design it is possible and common to assign multiple terms.

In which case if you were to visit a post which had both the region terms "south" and "west" assigned, what should the URL be?

site.com/south/post-name/ or site.com/west/post-name/

Now, WordPress lets you use the dynamic %category% placeholder when constructing custom URLs for posts, but there is no equivalent %my-custom-taxonomy% that you can use when setting custom URLs for your post type in its options.

To do so requires coding your own rewrite rules where you make your own placeholder such as %my-custom-taxonomy% and use it in your rewrite rules.

The closest example I found in a quick google search if you want to try to implement this yourself was https://wordpress.stackexchange.com/questions/39500/how-to-create-a-permalink-structure-with-custom-taxonomies-and-custom-post-types

#603675

Thanks very much Nigel,

Did some digging as well and you're right, the custom code way is the only one.

#603693

Hi Nigel,

Not re-opening this thread, but I found a solution I'd like to share with others that might be having the same issue.

I'm no stranger to the rewrite rules, but it's coding I don't feel like doing so I found a plugin that can tackle the problem just as easily.

The plugin can be located here: https://wordpress.org/plugins/custom-post-type-permalinks/
I would also advise folks to read a good how to here: hidden link

#603700

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Thanks for sharing that. I took a look at the plugin and it seems to do exactly what you need, and I'll make a note of it for future reference.

#603714

Awesome! 🙂