Permalinks Issues for Custom Post Types with Parents
|Reported by:||mikeschinkel||Owned by:|
|Component:||Posts, Post Types||Keywords:||reporter-feedback|
When a custom post type is assigned a value for post_parent via a custom metabox then it's permalink fails because the rewrite rules for register_post_type() don't allow paths longer than two segments.
The URL can be fixed by removing the parent path segment via the "post_type_link" hook but doing so does not fix the "sample" URL displayed in the editor. This confuses my end user because the URL he sees is not the actual URL that works and there is no hook to allow me to fix this.
We could add a filter on the return value for get_sample_permalink() but it feels like that's just patching the problem because it requires two hooks to be coded to addedd this problem instead of allowing WP core to recognize the pattern of having custom post types with parents. So I don't know what the proper solution is which is why I am not attaching a patch here.
To understand my use case I have a custom post type called "Restaurant" and another called "Restaurant Location." Clearly a Restaurant is a parent of a Restaurant Location, right?
My URL templates are like this:
And my actual URLs might look like this:
What shows up in the editor is this with the latter segment editable (notice how the base segment is "restaurant-locations" and not even "restaurants":
BTW, I'd really prefer to be able to have the following but to have the following would take a lot more UX surgery on the core and the admin editor than I think is smart for a plugin to attempt to perform (assuming it is even possible):
Change History (10)
- Component changed from General to Post Types
- Keywords reporter-feedback added
- Version set to 3.0
- Milestone Unassigned deleted
- Resolution set to worksforme
- Status changed from new to closed