• mharkrollen

    (@mharkrollen)


    Hi,

    Before, I was having trouble removing the wrapping div in calling wp_nav_menu. And found out that this code
    $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";' in post-template.php does the wrapping of div in menu items which happens when there is no menu item specified in the back end. I would suggest to add if statement for this code to have the ability to turn on/off the div wrap.

    ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter mharkrollen

    (@mharkrollen)

    If anybody still having trouble removing the div wrap in calling wp_nav_menu just remove this code

    $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";' in wp-includes/post-template.php

    if you want to have the ability to turn it on/off

    add this line before it

    if($args['container'])

    and in your wp_nav_menu add a parameter

    'container' => ''

    esmi

    (@esmi)

    No! Never, ever, edit WordPress core files.

    Thread Starter mharkrollen

    (@mharkrollen)

    you are right,. another solution without editing the core files is copy the function wp_page_menu from post-template.php and place it inside functions.php rename function to wp_page_menu-2

    and remove the code
    $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";'

    In your wp_nav_menu, add the parameter 'fallback_cb' => 'wp_page_menu-2'

    ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Ability to remove wrapping div in menu’ is closed to new replies.