WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 2 years ago

Last modified 2 years ago

#6211 closed enhancement (duplicate)

allow identical taxonomy slugs in different taxonomies

Reported by: nerrad Owned by: ryan
Milestone: Priority: normal
Severity: normal Version: 2.5
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Expected usage:
I create a category named "Planning for WordPress Upgrades" with the slug "planning" and save. With permalinks on the url would be something like, "http://www.mydomain.com/%categorytoken%/planning.

I create a tag named "planning" and save. With permalinks on the url would be something like "http://www.mydomain.com/%tagtoken%/planning".

However:
When saving the tag it will inherit the title of the preexisting category instead of saving as the tag I created. There should be no inheritance between taxonomy's.

Also, when editing the name in either the category or the tags the name will be changed in both the tag taxonomy and the category taxonomy. It is not possible to have different names for different taxonomies with the same slug.

Attachments (2)

same-slug-diff-taxonomy.patch (858 bytes) - added by nerrad 6 years ago.
patch to be applied after removing unique index key for the slugs field in the _terms table
same-slug-diff-taxonomy-2.patch (1.7 KB) - added by nerrad 6 years ago.
adds BOOL canonical param to $args for wp_insert_term

Download all attachments as: .zip

Change History (23)

comment:1 nerrad6 years ago

  • Keywords needs-patch added

comment:2 nerrad6 years ago

Looks like this can't be fixed because the current db schema slugs have a UNIQUE key in the _terms table. I can understand wanting to make sure that there are unique slugs per taxonomy but isn't it overkill to have unique slugs across all taxonomies?

I understand the necessity for unique slugs with posts but the current default permalink structure would allow for like slugs in different taxonomies.

I propose that the SLUG field in the _terms table not be UNIQUE and the suggested attached patch be applied to allow identical slugs in different taxonomies

nerrad6 years ago

patch to be applied after removing unique index key for the slugs field in the _terms table

comment:3 nerrad6 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:4 nerrad6 years ago

  • Summary changed from new terms created with a slug already in db will inherit title of existing term in db even if is different taxomony. to allow identical taxonomy slugs in different taxonomies

comment:5 follow-up: ryan6 years ago

  • Milestone changed from 2.5 to 2.6

Taxonomy was designed to keep terms canonical between categories. We can revisit that decision, but not for 2.5.

comment:6 ryan6 years ago

Between taxonomies, I should say.

comment:7 in reply to: ↑ 5 nerrad6 years ago

Replying to ryan:

Taxonomy was designed to keep terms canonical between categories taxonomies. We can revisit that decision, but not for 2.5.

Understood - hope it gets revisited :)

comment:8 nerrad6 years ago

Keep in mind when revisiting. This decision regarding taxonomies affects not only category and tag intersections but also any future taxonomies plugin authors create. To keep terms canonical between category and tags is one thing but to force that on all future taxonomies might not be the best route to take.

I suggest adding a new 'canonical' paramater to the $args variable that defaults to true and running the current code. Plugin authors can set it to "false" (when calling wp_insert_term to allow inserting a slug with the same name as another taxomony for their taxonomy.

Of course this still requires dropping the index for slugs in the wp_terms table.

nerrad6 years ago

adds BOOL canonical param to $args for wp_insert_term

comment:9 hakre6 years ago

Please keep it unique until there is a full featured object modell for anything taxonomic. This here and there hushing leads to nothing but even more chaos. The way it is done now is not that nice but the most failsafe for the time being.

nerrad, even your patches do not fully reflect multiple taxonomies. you just passed it as useless parameter that's all. those different taxonomies have to be reflected in the datastructure as well.

comment:10 janbrasna5 years ago

  • Cc janbrasna added
  • Component changed from Administration to Taxonomy
  • Keywords category tag permalink slug taxonomy unique added
  • Owner changed from anonymous to ryan

Related: #3799 + #3683 + #5034 + #6542

comment:11 Denis-de-Bernardy5 years ago

  • Cc Denis-de-Bernardy added

comment:12 Denis-de-Bernardy5 years ago

  • Severity changed from blocker to normal

comment:13 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch needs-testing removed
  • Milestone changed from 2.9 to Future Release
  • Priority changed from high to normal
  • Type changed from defect (bug) to enhancement

comment:16 kevinB4 years ago

  • Cc kevinB added

comment:17 dd323 years ago

Closed #12911 as duplicate

comment:18 scribu2 years ago

Related: #19169

comment:20 johnbillion2 years ago

  • Keywords needs-patch category tag permalink slug taxonomy unique removed
  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is the same issue as #5809, just with different terminology. Closing as dupe as #5809 has patches.

comment:21 lkraav2 years ago

  • Cc lkraav added
Note: See TracTickets for help on using tickets.