[wp-trac] [WordPress Trac] #19499: Allow wp_nav_menu to return just the links (no <li> tags)

WordPress Trac wp-trac at lists.automattic.com
Sat Dec 10 12:15:35 UTC 2011


#19499: Allow wp_nav_menu to return just the links (no <li> tags)
--------------------------+-----------------------------
 Reporter:  nohalfpixels  |      Owner:  nohalfpixels
     Type:  enhancement   |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  3.2.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 every now and again i find im in the need of the wp_nav_menu function
 where i only want a list if links, not the outer ul, or the li tags.

 there is already scope to remove the outer ul.

 but no support for removing the <li> tags from the returned results.

 at present i have to do this:


 {{{
 $foot_nav = wp_nav_menu( array( 'container' => '', 'echo' => '0',
 'theme_location' => 'footer_menu' ) );
 $foot_nav2 = preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '',
 $foot_nav );
 $foot_nav2 = preg_replace( array( '#<li[^>]*>#', '#</li>$#' ), '',
 $foot_nav2 );
 echo $foot_nav2;
 }}}



 this isnt very clean, it would be nice to just be able to pass a parameter
 the wp_nav_menu function which just returns the links.

 i propose something like:


 {{{
 'return_links' => true,
 }}}



 the main reason for this is styling centered links in the footer.

 its much easier to just center links than it is to center a <ul> and
 results in much cleaner html with less dom elements.

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


More information about the wp-trac mailing list