[wp-trac] [WordPress Trac] #21525: wp_list_pages: current page css fails with custom post types

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 9 09:27:43 UTC 2012


#21525: wp_list_pages: current page css fails with custom post types
---------------------------+-----------------------------
 Reporter:  martin.czerwi  |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Post Types     |    Version:  3.4.1
 Severity:  normal         |   Keywords:
---------------------------+-----------------------------
 In a customer project I used a custom post type 'products' for content-
 pages. 'products' is registered with 'public' => true and 'hierarchical'
 => true.

 For a sub navigation I'm using wp_list_pages() to list all sibling
 'products'. Usually you get css-classes in the output, to highlight the
 current pages, or ancestors and so on. This works fine, when using regular
 pages, but when using my custom post type, the current page isn't
 highlighted, the class is missing.

 I looked at the code and after testing a bit I discovered walk_page_tree()
 receives '0' as the $current_page parameter. That's the reason why no css-
 classes for the current page are output.

 In wp-includes/post-template.php in wp_list_pages()
 ([http://core.trac.wordpress.org/browser/trunk/wp-includes/post-
 template.php#L828]) the $current_page parameter for walk_page_tree() is
 determined. When you have a custom post-type the if statement fails:
 {{{
 if ( is_page() || is_attachment() || $wp_query->is_posts_page )
     $current_page = $wp_query->get_queried_object_id();
 }}}

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


More information about the wp-trac mailing list