Take the 2-minute tour ×

I'm pretty new with WordPress and I want to create my own dropdown menu without the use of any plugins. I already did some research but there are some things I do not understand. In my header file I have the following code for my main menu:

<div id="navigation">

I didn't have to add any code in my functions.php file, it worked well without it. In most tutorials, you have to add this code in to the functions.php file, but for me it worked without this code.

add_action( 'init', 'register_my_menus' );
function register_my_menus() {
    register_nav_menus( array(
        'main' => __( 'main' ),

When I want to add a custom menu in WordPress, I have to add something to this code:

add_action( 'init', 'register_my_menus' );
function register_my_menus() {
    register_nav_menus( array(
        'main' => __( 'main' ),
        **'secondary-menu' => __( 'Secondary Menu' ),**

From this moment on, I can see 3 menus in the backend (2X primary menu, 1X secondary menu). I know this was a lot, but I have tried to be clear and I hope somebody will understand me. Can somebody please tell me where I'm going wrong?

share|improve this question
Is your question "How do I display a nav menu" or is it "I have a working nav menu, but how do I create drop down menus?" –  Tom J Nowell Jan 24 '13 at 10:17
@TomJNowell I have a workig nav menu and i want to create a dropdown menu. Above you see the things I already did. My question now is. Were this the right steps to create a dropdown menu? Is there something else i have to do or is just a matter of css now? –  Niels Jansen Jan 24 '13 at 10:21
Ah if you have a working menu then it is indeed a pure CSS question –  Tom J Nowell Jan 24 '13 at 10:46
@TomJNowell My main menu is fully working. It is just my submenu that is not working and I dont know if i did the right things (see above) to get it working. In my view that is not the right solution because a dropdown menu is not a secondary menu? –  Niels Jansen Jan 24 '13 at 10:50
Sub menus would be children, it's purely a CSS issue, look up CSS drop menus –  Tom J Nowell Jan 24 '13 at 10:59

1 Answer 1

For the moment based on your question I am assuming you want a single menu, which when hovering over a menu item, its child items are displayed in a drop down menu.

Following this tutorial should give you a horizontal menu with vertical drop downs:


Repeat for each menu you need.

For more on defining and using menus themselves in PHP, refer to this article by Justin Tadlock:


share|improve this answer
Thanks for your answer, I was a little bit confused about the different types of menus you have in wordpress. I think I only have to change some CSS to 'create' my dropdown menu. I do not want an extra menu (secondary menu) so why do I have to change PHP code then. I think I understand it now and this is my conclusion. If you want a dropdown menu (hoover over an item, child item appears in dropdown) you only need to change some css. If you want an extra menu for example a primary menu and a secundary menu, you have to change the php code ect. Can you please tell me if i'm correct? –  Niels Jansen Jan 24 '13 at 17:22
How the menu appears is CSS based, not PHP. PHP defines the menu, CSS styles it. Dropdowns are not separate menus, they're a part of the main menu. –  Tom J Nowell Jan 24 '13 at 17:29
Thank you for explaining this. I'm going to "copy" the css from the twenty eleven theme :-). I will let you know if everything is done. –  Niels Jansen Jan 24 '13 at 17:43

Your Answer


