[wp-trac] [WordPress Trac] #13490: Permalinks Issues for Custom Post Types with Parents

WordPress Trac wp-trac at lists.automattic.com
Sat May 22 05:04:04 UTC 2010


#13490: Permalinks Issues for Custom Post Types with Parents
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:            
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 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:

 {{{
 http://example.com/restaurants/%restaurant%/
 http://example.com/restaurant-locations/%restaurant-location%/
 }}}

 And my actual URLs might look like this:

 {{{
 http://example.com/restaurants/johns-seafood/
 http://example.com/restaurant-locations/johns-seafood-miami/
 }}}

 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":

 {{{
 http://example.com/restaurant-locations/johns-seafood/johns-seafood-miami/
 }}}

 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):

 {{{
 http://example.com/restaurants/johns-seafood/
 http://example.com/restaurants/johns-seafood/miami/
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13490>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list