WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Without using plugins, how to create a custom WordPress navigation menu with the code?
I have Wordpress ver 3.2.1
and Buddypress ver 1.5.1

I would like to create a menu.

I would like to place the buddypress menu navigation items into one item (social). when you pass the mouse over this item it appears the buddypress menu items in style Drop-Down Menu.

Can you help me? Thank you and sorry for my bad english!

share|improve this question
up vote 2 down vote accepted

Well first of all you can use the menu feature in the newer WordPress.

First you want to activate the fact that you want to use this feature via your functions.php file.

// This theme uses wp_nav_menu() in two locations.  
register_nav_menus( array(  
'primary' => __( 'Primary Navigation', 'your_theme_name' ),  
'secondary' => __('Secondary Navigation', 'your_theme_name')  
) ); 

The above code defines if you have more than one menu. If you want just one menu delete the secondary. If you do this it would look something like this in your functions.php file:

// This theme uses wp_nav_menu() in two locations.  
register_nav_menus( array(  
'primary' => __( 'Primary Navigation', 'your_theme_name' )
) );

This will now give you the option to add page items via the menu option under Appearance in the back-end.

Next in your theme you will want to add this to where you want the menu to appear:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' =>   'primary' ) ); ?>

The term "menu-header" will be the class of the div tag that the menu gets put in to. You can change this to whatever class you want the div tag to be in your theme.

Next everything else is done entirely via CSS.

Style declarations for Top Menu
.menu-header {
margin-right: auto;
margin-left: auto;
z-index: 10;

.menu-header li {
display: inline;
list-style: url(none) none;
float: left;

.menu-header ul {
line-height: 31px;

.menu-header a, .menu-header a:hover {
border:medium none;

.menu-header a, .menu-header a:visited {
padding:0 20px;

.menu-header a:hover, .menu-header a:active, .current_page_item a, #home .on, .menu-footer a:hover {

.menu-header li ul {

.menu-header li li {

.menu-header li li a, .menu-header li li a:visited {

.menu-header li li a:hover, .menu-header li li a:active {
background:#60625C none repeat scroll 0 0;
text-decoration: none;

.menu-header li:hover ul, .menu-header li li:hover ul, .menu-header li li li:hover ul,   .menu-header li.sfhover ul, .menu-header li li.sfhover ul, .menu-header li li li.sfhover ul     {

Just make what changes you need to, to make it look like the example you have posted.

share|improve this answer
Thank you @Nicole! – Phoenix Oct 28 '11 at 15:42
No problem! Have fun with it. :) – Nicole Oct 28 '11 at 16:15

WordPress has Custom Navigation Menus built-in.

Simply register a theme_location for each menu in functions.php, then go to Dashboard -> Appearance -> Menus to create the custom menu(s), and apply the custom menu(s) to the appropriate Theme Location(s).

The rest is a matter of CSS (or jQuery, if you really want to go that route).

share|improve this answer
Thank you @Bennett! – Phoenix Oct 28 '11 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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