• globheal

    (@globheal)


    Hey,

    I’m new with wordpress and i need help really fast, because i’m running out of time. I need to create menu in sidebar that after i click on link “A” it will drop down pages under it without redirecting to anotherpage.

    My menu looks like this:

    <ul class="purp_bullet">
            <li><a href="#sub-1">A/a>
                <ul id="sub-1">
                    <li><a href="link">B</a></li>
                    <li><a href="link">B</a></li>
                    <li><a href="link">B</a></li>
                    <li><a href="link">B</a></li>
                    <li><a href="link">B</a></li>
                </ul>
            </li>
            <li><a href="#sub-2">C/a>
                <ul id="sub-2>
                    <li><a href="link">D</a></li>
                    <li><a href="link">D</a></li>
                    <li><a href="link">D</a></li>
                    <li><a href="link">D</a></li>
                    <li><a href="link">D</a></li>
                </ul></li>
            <li><a href="link">E</a></li>
            <li><a href="link">F</a></li>
            <li><a href="link">G</a></li>
        </ul>

    With CSS like this:

    ul.purp_bullet {
        list-style-image: url('img/list_bullet.png');
        padding-left: 17px;
        text-decoration: none;
    }
    ul.purp_bullet li a {
        color: #003366;
        text-decoration: none;
    }
    ul.purp_bullet li a:hover {
        color: red;
        text-decoration: none;
    }
    ul.purp_bullet li a:active {
        color: red;
        text-decoration: bold;
    }

    When it’s static menu (just html and css) it works fine, the problem comes when i want to create this menu with admin panel in WP.

    I have registered new menu in functions.php like this:
    register_nav_menus(array('side-nav' => 'side menu'));

    and put it in my sidebar.php like this:

    <div class="col-md-3 shortcuts">
    	<div class="inner">
    		<h2>Na skróty</h2>
    
    			<?php wp_nav_menu(array('theme_location' => 'side-nav', 'menu_class' => 'purp_bullet', 'walker' => new My_Walker_Nav_Menu())); ?>
    
    		<?php dynamic_sidebar('sidebar-left', array('menu_class' => 'purp_bullet')); ?>
    	</div>
    </div>

    I came to conclusion that i need id=”#sub-1″ in my second ul so i found walker code on internet like this:

    class My_Walker_Nav_Menu extends Walker_Nav_Menu {
    	  function start_lvl(&$output, $depth) {
    		$indent = str_repeat("\t", $depth);
    		$output .= "\n$indent<ul id=\"#sub-1\">\n";
    	  }
    	}

    but even with this code it just doesn’t work.

    The drop down menu after click in first link (“Pracownicy” sorry for Polish lang) should look like this: http://i.stack.imgur.com/u7ZL9.jpg

    in final version of the menu there will be two drop down links that should work like the one in this picture.

    I know how to make :hover menu and it works, but i need it to be clicked and i run out of ideas how to make it.

    Can anyone guide me step by step what to do?

  • The topic ‘Submenu doesn't drop down after click – problem’ is closed to new replies.