WordPress.org

Ready to get started?Download WordPress

Forums

One thing wp_nav_menu should be able to remove (3 posts)

  1. heyarny
    Member
    Posted 3 years ago #

    Now as 3.0 gives us more abilities to customize navigation menus using wp_nav_menu and Walker_Nav_Menu, there is one thing left:

    nav-menu-template.php:219
    $nav_menu .= '<ul'. $attributes .'>';

    We are still forced to use <ul> ?
    I don't see a way to remove <ul> for specific navigation menus.

    If I'm mistaken here, please give me an advise.

  2. You can style uls with CSS, but yes, we still use ul. That's good HTML.

  3. sammyb
    Member
    Posted 3 years ago #

    ul is obviously 'good html', but what if you don't want it?

    you could always set the 'echo' parameter to false and then use preg_replace to remove the ul / li tags.

    example:

    $sub_menu = wp_nav_menu(array( 'echo' => '0'));
    $rep[1]='/<ul (.*?)>/i';
    $rep[2]='/<\/ul>/';
    $repl[1]='';
    $repl[2]='';
    echo preg_replace($rep,$repl,$sub_menu);

Topic Closed

This topic has been closed to new replies.

About this Topic