1

all

       As per my html theme structure i do not want to add my menu <ul><li> under <div>.

I am using

 <?php wp_nav_menu( array( 'menu_class' => 'tlm', 'theme_location' => 'primary-menu' ) ); ?>

By default this wrap my menu with div. like

<div class="menu-first-container"><ul class="tlm" id="menu-first"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-23" id="menu-item-23"><a href="http://localhost/tmw_new/">Dashboard</a></li>
<li class="hasul menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-58" id="menu-item-58"><a href="#">Patients</a>
<ul class="sub-menu">
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27" id="menu-item-27"><a href="http://localhost/tmw_new/?page_id=25">Patients</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-55 current_page_item menu-item-57" id="menu-item-57"><a href="http://localhost/tmw_new/?page_id=55">Add Patients</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-62" id="menu-item-62"><a href="http://localhost/tmw_new/?page_id=60">Calender</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-66" id="menu-item-66"><a href="http://localhost/tmw_new/?page_id=64">Images</a></li>
</ul>
</li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-67" id="menu-item-67"><a href="http://google.com">Support</a></li>
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-68" id="menu-item-68"><a href="#">Logout</a></li>
</ul></div>

How to remove div container in custom menu ? as i can think there may be need some change in wp_nav_menu() function array.

2 Answers 2

4

Set the container to be empty. :)

wp_nav_menu( array(
    'menu_class' => 'tlm',
    'theme_location' => 'primary-menu',
    'container' => ''
) );

Please refer to the function reference to review all the arguments that you can pass to wp_nav_menu().

2

You can use the parameter to remove the div container

http://codex.wordpress.org/Function_Reference/wp_nav_menu

there is a "container" class to change main container. you can change it to anything or put '' null to remove the container.

3
  • sorry its my fault that i am not defining 'container' => '' it. Without define this blank its take automatically div and its id. BTW thanks
    – Ajay Patel
    Commented Feb 1, 2012 at 13:14
  • one more think if u can help me ... as you can see li tag <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27" id="menu-item-27"><a href="localhost/tmw_new/?page_id=25">Patients</a></…> i want to make it like <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-27" id="menu-item-27"><a href="localhost/tmw_new/?page_id=25"><span>Patients</…> (<span>)
    – Ajay Patel
    Commented Feb 1, 2012 at 13:26
  • did it using 'link_before' => , 'link_after' => ,
    – Ajay Patel
    Commented Feb 1, 2012 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.