Opened 13 years ago
Closed 10 years ago
#19499 closed enhancement (wontfix)
Allow wp_nav_menu to return just the links (no <li> tags)
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | Menus | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (5)
Note: See
TracTickets for help on using
tickets.
You could use
wp_get_nav_menu_items()
to get an array with all the elements, without formatting. That way, you could create your own HTML around it, e.g. like they do in http://digwp.com/2011/11/html-formatting-custom-menus/Does that maybe solve your problem?