Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#8673 closed enhancement (fixed)

Missing capability to override Walker_Page

Reported by: mikelittle's profile MikeLittle Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: has-patch
Focuses: Cc:

Description

Summery: PATCH to add the ability to override Walker_Page and Walker_PageDropdown.

I noticed that unlike the Comment Walker which can be overridden by a user supplied object, there is no way to override the page walker (Walker_Page) or the dropdown page walker (Walker_PageDropdown).

Attached is a patch which adds the ability to supply your own walker objects to both functions.
It uses the same method as for Walker_Comment (a instantiated class supplied to the wp_list_pages() or wp_dropdown_pages() function call.

Note: The method of checking for the added parameters was different for wp_dropdown_pages(), for some reason it does not pass the (fixed) parameters to walk_page_dropdown_tree() unlike those passed to walk_page_tree().

Attachments (2)

post-template.php.patch (1.0 KB) - added by MikeLittle 16 years ago.
Patch against rev 10226 to implement custom Walker_Page and Walker_PageDropdown
add-to-functions.php (2.6 KB) - added by MikeLittle 16 years ago.
Trivial example of overriding Walker_Page and Walker_PageDropdown

Download all attachments as: .zip

Change History (5)

@MikeLittle
16 years ago

Patch against rev 10226 to implement custom Walker_Page and Walker_PageDropdown

#1 @MikeLittle
16 years ago

Here is a trivial example of using the new capability.

Add the attachment add-to-functions.php to functions.php in your theme. Add the following calls in your sidebar.

<?php wp_list_pages(array('title_li'=>'<h2>Pages</h2>', 'walker' => new zed1ExamplePageWalker) ); ?>

<?php wp_dropdown_pages(array('title_li'=>'<h2>Pages</h2>', 'walker' => new zed1ExampleDropdownPageWalker) ); ?>

@MikeLittle
16 years ago

Trivial example of overriding Walker_Page and Walker_PageDropdown

#2 @MikeLittle
16 years ago

  • Keywords has-patch added; haspatch removed

#3 @ryanLead Tester
16 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10230]) Allow custom page walker classes. Props MikeLittle. fixes #8673

Note: See TracTickets for help on using tickets.