WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#16832 new defect (bug)

Trouble if the slug of a custom taxonomy is the same as the url of page/post

Reported by: LucasHantz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Rewrite Rules Keywords: needs-patch
Focuses: Cc:

Description

I got some troubles with the 3.1 version of WordPress concerning the slug of custom taxonomy.

An example that work in 3.0.5
www.example.com/agency (url of a page)
www.example.com/agency/john-smith (url of a custom type's detail)

Apparently having the same "folder" 'agency' only works for one or the other url but not both.

Hope I made myself clear.

Change History (9)

comment:1 scribu3 years ago

  • Keywords needs-patch added

You can use the 'wp_unique_post_slug_is_bad_flat_slug' filter to prevent collisions.

WP should handle that case automatically, though.

comment:2 sterlo3 years ago

I've had the same issue.

If the problem is that you have a folder called "agency" and a taxonomy called "agency" and it's choosing the folder over the taxonomy - you need to use wp_rewrite to tell it what it should be doing.

comment:3 follow-up: scribu3 years ago

@sterlo: That's different. First of all, WP always gives way to actual files. Secondly, WP doesn't have a taxonomy index, so /agency/ would return a 404 anyway.

comment:4 in reply to: ↑ 3 sterlo3 years ago

Replying to scribu:

@sterlo: That's different. First of all, WP always gives way to actual files. Secondly, WP doesn't have a taxonomy index, so /agency/ would return a 404 anyway.

WordPress by "Default" does not have a taxonomy index.

You can add it and it won't return a 404.

If he tries to get to page www.example.com/agency <- by default the page would show.

If he tries to go to www.example.com/agency/john-smith <- by default the taxonomy shows.

He could make www.example.com/agency point to the taxonomy still or whatever he wants it to point to for that matter - a file/page/taxonomy etc.

comment:5 scribu3 years ago

Sure, but my first point still stands. The default .htaccess rules prevent WP from loading when a file or directory is present at a certain URL. That's not going to change.

comment:6 mikeschinkel3 years ago

  • Cc mikeschinkel@… added

comment:7 andrewryno3 years ago

Not sure if it's related but I'm running into an issue that may stem from this.

I have one page at /work/. There are subpages of that main page (for example /work/philosophy/) as well as post types that use that same slug (/work/work-name/) and it's colliding. When trying to access a subpage, it returns a 404 because it is looking for a post within that post type.

Not the best architecture, I admit, but it might be possible for WP to search for subpages if it can't find a post for that post type (and if it has the same slugs). Though I'm probably going to just change the way I am doing things, just thought I'd add this.

comment:8 tomauger3 years ago

I might take a crack at this since it's something I'm running into a lot - basically in the context of wanting to create a main "taxonomy" landing page - both as a menu item and as a sort of meta-archive, such that if I go to /blog/my-custom-tax/ I can get an archive page that lists all the terms in that taxonomy. It would be best if this page's URL were the same as the tax's rewrite slug, for a better user experience in terms of the URI. /blog/my-custom-tax/term-one/ would of course be the archive page for a single term of the same taxonomy.

Okay, so before I even consider looking into this, I'd like to know, particularly from Scribu, what's the angle: get WP to enforce that a page slug can NOT be the same as the rewrite slug of a custom taxonomy? or figure out how to allow a "taxonomy landing page" type structure - whether it's a new kind of template file, or just a page that you manually assign a slug to like we do now, and figure out what, in the rewrite class is making it such that it gives us a 404 today?

comment:9 scribu3 years ago

With a clean WP 3.3 install, I can create a /tags/ page with a custom template and also have /tags/foo/ for a single tag. It just works.

If this doesn't work for custom taxonomies, it's a bug, IMO.

For custom post types, it's not so clear cut, since they have the 'has_archive' parameter.

Last edited 3 years ago by scribu (previous) (diff)
Note: See TracTickets for help on using tickets.