Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to change the way of rendering menu in WordPress - I guess I should write my own walker class but I'm not sure how to bite it. What I'd like to achieve is to render each level of menu as separate div. So we have pretty standard wp menu:

<ul class="dropmenu main-menu" id="menu-some-stupid-name">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-83" id="menu-item-83">
    <a href="http://localhost/wordpress/flext/contact/">Contact</a></li>
    <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-85" id="menu-item-85">
        <a href="http://localhost/wordpress/flext/blog/">Blog</a>
        <ul class="sub-menu"> 
            <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99" id="menu-item-99"><a href="http://localhost/wordpress/flext/blog/">Blog</a></li>  
        </ul>
   </li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-9 current_page_item current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-86" id="menu-item-86"><a href="http://localhost/wordpress/flext/">Home</a>
        <ul class="sub-menu">  
            <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-9 current_page_item menu-item-101" id="menu-item-101"><a href="http://localhost/wordpress/flext/">Home</a></li>   
            <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102" id="menu-item-102"><a href="http://localhost/wordpress/flext/sample-page/">Sample Page</a></li>
        </ul>
    </li>
</ul>

What I'd like to achieve is this:

   <ul class="dropmenu main-menu" id="menu-some-stupid-name">
        <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-83" id="menu-item-83"><a href="http://localhost/wordpress/flext/contact/">Contact</a></li>
        <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-85" id="menu-item-85"><a href="http://localhost/wordpress/flext/blog/">Blog</a></li>
        <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-9 current_page_item current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor menu-item-86" id="menu-item-86"><a href="http://localhost/wordpress/flext/">Home</a></li>
    </ul>

    <ul class="sub-menu child-menu-item-85"> 
        <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99" id="menu-item-99"><a href="http://localhost/wordpress/flext/blog/">Blog</a></li>  
    </ul>

    <ul class="sub-menu child-menu-item-86">  
        <li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-9 current_page_item menu-item-101" id="menu-item-101"><a href="http://localhost/wordpress/flext/">Home</a></li>   
        <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102" id="menu-item-102"><a href="http://localhost/wordpress/flext/sample-page/">Sample Page</a></li>
    </ul>

Is it possible to achieve with custom Walker_Nav_Menu class? I'd really appreciate any ideas. Thanks

share|improve this question
    
IMO, your best bite is take any of the examples you find in this very Stack and poke with it, and then come back and improve your Question :) –  brasofilo Nov 25 '12 at 21:31

1 Answer 1

I've decided to not change anything in walker class and "parse" the menu with jQuery, clone each children and append to "menu" container which gives me the result I was looking for. The only thing missing is how to pass ID of menu element which has childrens to start_lvl function.

Thanks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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