#15082 closed defect (bug) (fixed)
Custom post type empty slug breaks permalinks for pages
Reported by: | firebird75 | Owned by: | |
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | normal | Version: | 3.0.1 |
Component: | Posts, Post Types | Keywords: | 2nd-opinion |
Focuses: | Cc: |
Description
If I register a custom post type using the register_post_type function and I pass the following parameter :
rewrite => array('slug' => )
If the blog permalink structure is set to /%postname%/, then it breaks the rewriting rules for pages (post of type page). They return a 404 error when you try to open it. You need to save at least one page after having registered the custom post type to see the issue.
Setting the custom post type slug to the value is made to have custom post type permalink structure match the blog permalink structure (ie only /%postname%/ in the url).
Attachments (1)
Change History (15)
#3
follow-up:
↓ 5
@
14 years ago
Well, I understand that there are some drawbacks around using /%postname%/ but fact is that it is very widely used right now. I'd like to avoid the SEO debate around it, there are as many different points of view as people on that ;)
If I am not using the register post type but rather directly tweak WP to work with a custom post type, I don't fall into this issue.
I don't know if this is something that can be fixed but it would be nice, for those that like the simple permalink structure...
#5
in reply to:
↑ 3
@
14 years ago
Replying to firebird75:
Well, I understand that there are some drawbacks around using /%postname%/ but fact is that it is very widely used right now. I'd like to avoid the SEO debate around it, there are as many different points of view as people on that ;)
I was refering strictly to performance, not SEO.
#6
@
14 years ago
@nacin : yes that's right, this is a possibility. I have absolutely no idea of how to achieve that but I could do some researches. Beside that, I can see how complex it is to tweak WP when you don't use the regular path so if I can avoid it ;)
@scribu : you are right, there is a performance impact but based on my experience, it won't multiply the page load time by 10... It is marginal so most users won't care about it and keep the permalink structure they prefer...
@
14 years ago
Prevent you from shooting yourself in the foot. Not convinced here, as they do work I guess, it just breaks something else.
#7
@
14 years ago
- Keywords 2nd-opinion added
Attached a patch that prevent you from shooting yourself in the foot. Not convinced here, as they do work I guess, it just breaks something else.
#8
@
14 years ago
Thanks for this Nacin!
If I understand well, you patch will prevent plugins from setting the slug to an empty value and then in that case default the slug to include the post_type, right?
This is probably a good idea as it will prevent the bug from showing up. It removes a bit of flexibility but since this one isn't working right now, it is probably better this way.
#12
in reply to:
↑ 10
@
13 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
- Version changed from 3.0.1 to 3.3.1
Replying to nacin:
(In [17298]) Don't allow an empty rewrite slug for CPT. If you need something like this, do rewrite=>false. fixes #15082.
How? There is gazillion ways to do this by Googling, but most of them overtly complicated for what it should be... Can't find the WP3.3 specific answer though! Some uses htaccess, some uses multiple tricks to rewrite the slug part with replacing string at some "handy spot".
Why can't there be API just like for regular post_type=post, where one can define "/%postname%/" in WP 3.3?
I know this is not Q&A, so I've started "Wordpress 3.3 custom post type with /%postname%/" in Wordpress StackExchange.
#13
@
13 years ago
- Resolution set to fixed
- Status changed from reopened to closed
- Version changed from 3.3.1 to 3.0.1
This ticket was closed on a completed milestone. I guess wp-hackers list would be the proper place for the discussion.
Version number indicates when the bug was initially introduced/reported.
First of all,
/%postname%/
is not a very efficient permalink structure:http://dougal.gunters.org/blog/2009/02/04/efficient-wordpress-permalinks
The following article explains why page permalinks are broken:
http://ottopress.com/2010/category-in-permalinks-considered-harmful/