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

WordPress Trac wp-trac at lists.automattic.com
Sun May 23 01:05:58 UTC 2010


#13490: Permalinks Issues for Custom Post Types with Parents
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:                   
     Type:  defect (bug)  |      Status:  new              
 Priority:  normal        |   Milestone:  Unassigned       
Component:  Post Types    |     Version:  3.0              
 Severity:  normal        |    Keywords:  reporter-feedback
--------------------------+-------------------------------------------------

Comment(by mikeschinkel):

 So, in the interest of bringing it full circle for others wanting to solve
 this problem (and hopefully for the core team to analyze and address to
 enable others in the future to deal with this in an easier manner) here is
 the code to make the menu and location pages only display one record:

 {{{
 add_filter('parse_query','tyc_parse_query');
 function tyc_parse_query($query) {
         if (isset($query->query_vars['restaurant-dummy'])) {
                 $restaurant = get_page_by_path($query->query_vars
 ['restaurant-dummy'],OBJECT,'restaurant');
                 $query->query_vars['post_parent'] = $restaurant->ID;
                 $query->query_vars['restaurant'] = $query->query_vars
 ['restaurant-dummy'];
                 unset($query->query_vars['restaurant-dummy']);

                 // Not sure if I really need to update ->query, but why
 not? Some plugin probably uses it.
                 $query->query['post_parent'] = $restaurant->ID;
                 $query->query['restaurant'] = $query->query['restaurant-
 dummy'];
                 unset($query->query['restaurant-dummy']);

         }
         return $query;
 }
 }}}

 '''NOTE:''' After editing the slug but before pressing publish the "View
 Location" and "View Menu" buttons don't work for Restaurant Location and
 Restaurant Menu, respectively. Ideally if this gets addressed in core they
 would be disabled or their hyperlink modified after clicking "Ok" to save
 the slug.

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


More information about the wp-trac mailing list