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.

so I've been searching around in the hope somebody also had this issue.. But I can't find any. I've currently created a Wordpress template out of a hardcoded HTML template for somebody.

Now here's the problem... He already had coded the dropdown function in CSS so it was my job to port it over to Wordpress but it doesn't seem to work out very well.

This is how it should look like (Note that there are three rows because there are three categories within the menu itself): This is how it should like

This is the HTML from the hardcoded template;

<li class="green">
    <a href="#">Evenementen</a>
    <ul class="submenu">
        <li>
            <ul>
                <li>
                    <a class="menu_title" href="#">Evenementen</a>
                </li>
                <li>
                    <a href="#">Braderie</a>
                </li>
                <li>
                    <a href="#">Jaarmarkten</a>
                </li>
            </ul>
        </li>
        <li>
            <ul>
                <li>
                    <a class="menu_title" href="#">Bedrijfsfeesten</a>
                </li>
                <li>
                    <a href="#">Sportfeesten</a>
                </li>
                <li>
                    <a href="#">Cateringbus</a>
                </li>
                <li>
                    <a href="#">Filmlocatiebus</a>
                </li>
            </ul>
        </li>
        <li>
            <ul>
                <li>
                    <a class="menu_title" href="#">Kinderfeesten</a>
                </li>
                <li>
                    <a href="#">Schoolfeesten</a>
                </li>
                <li>
                    <a href="#">Familiedagen</a>
                </li>
            </ul>
        </li>
    </ul>
</li>

What I myself have so far is in the header.php at the moment:

     <a href="<?php bloginfo('url'); ?>">Home</a></li>
     <?php wp_nav_menu('title_li=&depth=2'); ?>

Functions.php :

add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {

$parents = array();
foreach ( $items as $item ) {
    if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
        $parents[] = $item->menu_item_parent;
    }
}

foreach ( $items as $item ) {
    if ( in_array( $item->ID, $parents ) ) {
        $item->classes[] = 'submenu'; 
    }
}

return $items;} 

EDIT: I've tried everything to look at the codex of wp_nav_menu, but I can't seem to make anything out of it. Someone told me that I'm not using it correctly, the thing is: Where am I not using it correctly? Is it in functions.php or header.php? I just need to port it over as it seems the most safest thing to do. I've never done such a dropdown menu before which is why I'm asking for a push in the right way.

share|improve this question

closed as too broad by t f, toscho Jan 7 at 18:18

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You're not using wp_nav_menu() correctly. Please refer to the Codex entry for wp_nav_menu(), correct your usage, and then report back with any issues remaining. –  Chip Bennett Jan 7 at 17:25
    
I thank you for your quick reply, but could you explain what you mean about me not using the wp_nav_menu correctly? I'm quite new to this. –  Ahmed Beni Touzine Jan 7 at 17:28
    
Please read the linked Codex entry. It explains correct usage of wp_nav_menu(). For further reference, read the Codex entry on Custom Navigation Menus. Explaining the entire implementation of the feature is too broad-scoped for WPSE. –  Chip Bennett Jan 7 at 17:44

1 Answer 1

up vote 0 down vote accepted

Better way is put:

 wp_nav_menu( array('menu' => 'Top menu','menu_class' => 'top_menu')); 

And then force your html classes to wordpress, or simply 5 min rewrite css rules, classies names for wordpress.

Wordpress uses ul li ul li ul li, and so on structure, and there is no problem to fix it.

share|improve this answer
    
You need to use theme_location, not menu, in your wp_nav_menu() call. –  Chip Bennett Jan 7 at 18:06
    
There is no metter :) –  Foxsk8 Jan 7 at 18:07
    
Actually, yes there is: a very significant matter. Using menu will force the wp_nav_menu() call to look for a user-defined nav menu with a specific name. Using theme_location will use whatever user-defined nav menu the user has applied to the registered Theme Location. Using menu in place of theme_location essentially bypasses the entire purpose of using wp_nav_menu() in the first place. –  Chip Bennett Jan 7 at 18:09
    
How can you force the HTML classes to Wordpress if I may ask? –  Ahmed Beni Touzine Jan 7 at 22:45
    
Rewrite html for wordpress class names. For exampe .menu ul li.current_page_item –  Foxsk8 Jan 7 at 23:41

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