[wp-trac] [WordPress Trac] #11095: Format wp_list_pages and wp_page_menu without <li> tags
WordPress Trac
noreply at wordpress.org
Thu Dec 11 03:35:17 UTC 2014
#11095: Format wp_list_pages and wp_page_menu without <li> tags
-------------------------------+-----------------------------
Reporter: zialingua | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: template
-------------------------------+-----------------------------
Changes (by stevegrunwell):
* keywords: => has-patch
Comment:
These have limited use (especially when 'title_li' is present), but with
the patch we can:
1. 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>
}}}
2. 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>
}}}
2. 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()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/11095#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list