Opened 17 years ago
Closed 11 years ago
#11095 closed enhancement (fixed)
Format wp_list_pages and wp_page_menu without <li> tags
| Reported by: | zialingua | Owned by: | wonderboymusic |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.4 |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | template |
Description
Would that be possible to have the functions wp_list_pages and wp_page_menu with an option to display pages in a "flat" format like the functions wp_list_bookmarks or wp_tag_cloud or wp_get_archives?
Attachments (2)
Change History (17)
#1
@
17 years ago
- Component General → Template
- Keywords wp_list_pages wp_page_menu removed
- Type defect (bug) → feature request
#4
@
12 years ago
- Keywords has-patch added
These have limited use (especially when 'title_li' is present), but with the patch we can:
- Flatten the output (without re-ordering)
<ul> <?php $args = array( 'format' => 'custom', 'before' => '<li class="%s">', 'after' => '</li>', 'title_li' => null ); wp_list_pages( $args ); ?> </ul> <!-- produces --> <ul> <li class="page_item page-item-1"><a href="http://src.wordpress-develop.dev?p=1">Parent Page</a></li> <li class="page_item page-item-3"><a href="http://src.wordpress-develop.dev?p=3">Child Page</a></li> <li class="page_item page-item-2"><a href="http://src.wordpress-develop.dev?p=2">Second Parent</a></li> </ul>
- Wrap links in other elements
<?php $args = array( 'format' => 'custom', 'before' => '<span class="%s">', 'after' => '</span>', 'title_li' => null ); wp_list_pages( $args ); ?> <!-- produces --> <span class="page_item page-item-1"><a href="http://src.wordpress-develop.dev?p=1">Parent Page</a></span> <span class="page_item page-item-3"><a href="http://src.wordpress-develop.dev?p=3">Child Page</a></span> <span class="page_item page-item-2"><a href="http://src.wordpress-develop.dev?p=2">Second Parent</a></span>
- Add icons, entities, or whatever other items (that should most likely be CSS pseudo-elements):
<?php $args = array( 'format' => 'custom', 'before' => '* ', 'title_li' => null ); wp_list_pages( $args ); ?> <!-- produces --> * <a href="http://src.wordpress-develop.dev?p=1">Parent Page</a> * <a href="http://src.wordpress-develop.dev?p=3">Child Page</a> * <a href="http://src.wordpress-develop.dev?p=2">Second Parent</a>
Patch also adds tests for wp_page_menu().
#5
@
11 years ago
- Keywords needs-patch added; has-patch removed
- Milestone Future Release → 4.4
- Type feature request → enhancement
Seems like wp_page_menu() needs to be able to accept 'walker' and remove some of the hardcoded HTML bits. wp_list_pages() already accepts 'walker'
#7
@
11 years ago
- Keywords needs-docs added
- Resolution fixed
- Status closed → reopened
Documentation for the three new arguments needs to be added to the hash notation for $args. Also, a changelog entry, please :-)
#13
@
11 years ago
- Resolution fixed
- Status closed → reopened
[34243] broke back compat for themes adding a home link by checking ! isset( $args['show_home'] ), including Twenty Ten and Twenty Eleven.
I think we should leave the docs but remove the actual declaration in the default array for show_home.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Adds 'format', 'before', and 'after' arguments to wp_list_pages()