Skip Navigation

[Resolved] Add taxonomy to URL

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

Problem:
The issue here is that the user wanted to add their taxonomy to the post type URL.

Solution:

Unfortunately this is not something that is possible to achieve out of the box and would require some amount of coding to achieve.

This support ticket is created 3 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 4 replies, has 3 voices.

Last updated by azzurraM 3 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#2110113

Tell us what you are trying to do?

Hi there,
I'm using the same archive template for both CPT and taxonomy.
CPT: distributori
taxonomy: regione
taxonomy terms: piemonte, abruzzo...
This is working fine except I get funny URLs:
domain/regione/piemonte -instead of-
domain/distributori/piemonte
How can I get my goal URL structure "domain/distributori/piemonte" that is domain/CPT/taxonomy-term?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2110225

Nigel
Supporter

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

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

Screenshot 2021-07-09 at 15.06.04.png

You want to change the permalinks for your taxonomy archive from

domain/taxonomy/term

to

domain/cpt-slug/term

correct?

That's not possible without a custom solution.

You can change the slug for the taxonomy archive in the settings when editing the taxonomy, but if you try to use the slug of a CPT you will see a warning notice (see screenshot), and I can confirm that trying to visit posts on the front end then fails.

You could try a 3rd party plugin to modify the permalinks structure (e.g. https://wordpress.org/plugins/permalinks-customizer/, but there are others), though I'm not sure you won't run into the same problem.

You may have to go down the route of writing your own custom rewrite logic using the WordPress rewrite API (https://developer.wordpress.org/apis/handbook/rewrite/). It might help to search for tutorials for that.

#2110293

Yes,
I don't understand, though. If taxonomies are children to CPTs, why don't URLs show this structure?
I would expect domain/CPT/taxonomy/taxonomy-term/CPT-name and not
domain/taxonomy/taxonomy-term totally skipping the CPT slug
Thank you

#2110453

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Azzurra,

This how wordpress designs its permalink structures, for you to add your taxonomy term to the custom post type URL you will need to try using the plugin that Nigel mentioned in his response or use custom code to add the custom taxonomy to your permalink structure.

As Nigel also mentioned you will need to employ the use of the wordpress rewrite rules to create your custom URL structure.

Thanks,
Shane

#2111959

OK, I expected more flexibility from Toolset in the URL management, but thanks anyway.