WordPress.org

Ready to get started?Download WordPress

Forums

wp_nav_menu, adding a div around the secondary ul (4 posts)

  1. yulichka
    Member
    Posted 2 years ago #

    Hello!
    I'm trying to re-work a hard-coded navigation menu into one that is controlled by WordPress.

    The basic setup of the hard-coded menu is:

    <div id="nav">
    	<ul>
    		<li><a>About Us</a>
    		    <div class="flare">
    			<ul>
    				<li></li>
    			</ul>
    		    </div><!--END .flare-->
    		</li>
    	</ul>
     </div><!--END #nav-->

    What I'm particularly after is the <div class="flare"> around the secondary ul. Is it possible to add that to a wp_nav_menu? I'm using Starkers and modifying as I go along.

    Any help would be greatly appreciated. Thanks!

  2. camelman
    Member
    Posted 2 years ago #

    Use a custom walker class (a nice tutorial here: http://wpquicktips.wordpress.com/2010/07/09/create-a-custom-menu-by-creating-your-own-walker/) and change the output any way you like :-)

  3. yulichka
    Member
    Posted 2 years ago #

    Thank you so much for the tutorial, I'll give it a try.

    Really, really appreciate it. Cheers!

  4. yulichka
    Member
    Posted 2 years ago #

    Just as a note for anyone who ends up with the same problem, here is the code I ended up using for the custom walker:

    class Walker_Page_Custom extends Walker_Nav_Menu {
    
    function start_lvl(&$output, $depth) {
        $indent = str_repeat("\t", $depth);
        $output .= "\n$indent<div class='flare'><ul>\n";
    	}
    
    function end_lvl(&$output, $depth) {
        $indent = str_repeat("\t", $depth);
        $output .= "$indent</ul></div><!--flare -->\n";
    	}
    
    }

    Thanks again for the help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags