I'm creating custom theme. I am struggling to create main menu with drop down. I created a menu with custom code:

            $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
            print drupal_render($main_menu_tree);

But it doesn't working as I want. I need to add class in that particular <UL> tags. How can I achieve that?

I tried to Hook custom function in templates file. But no luck. How to call custom function into view page?

Below are some more screenshots.

Main menu with correct:

Main menu with correct

Menu with Wrong:

main menu with wrong

How to call custom menu design in custom theme?

1 Answer 1


You can use Menu Attributes Module to add classes.

This simple module allows you to specify some additional attributes for menu items such as id, name, class, style, and rel.

To custom code it, you can add class to menu links using hook_menu_link_alter . Try something like this:

$item['options']['attributes']['class'] = array('class-one' , 'class-two');

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.