One of the best features in the WordPress 3.x is the ability to add multiple Menus from pages, posts, customs posts types or even just anything as you desire. It’s very easy to first register custom menu in the admin panel and then call in your theme files and style them as you want.
To add a custom Menu option on your theme, add this to your theme function.php file:
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array(
'footer_menu' => 'My Custom Footer Menu',
'portfolio_sidebar_menu' => 'Portfolio Sidebar Menu',
'services_sidebar_menu' => 'Services Sidebar Menu'
)
);
}
//this will three custom menus options in your WP-Admin menus
Inside your theme file, her;es how you cxall this above menu. Make sure you add some menus items using WP-Admin before calling it. I’m disabling the navigation container div and assignign it a specific class left-sidebar in the arguments to style the menus.
$args = array('container'=>'',
'menu' => 'portfolio',
'items_wrap' => '
‘ ); wp_nav_menu( $args );
Here’s the css for styling:
.left-sidebar {
width: 228px;
margin:0 auto;
list-style-type: none;
text-align: center;
}
.left-sidebar li a, .left-sidebar li a:visited{
display:block;
padding-top:1.3em;
background:url('images/button.png') center bottom no-repeat;
font-size: 18px;
color: #ffffff; font-weight: bold;
text-decoration: none;
height: 58px;
margin-bottom: 5px;
}
.left-sidebar li a:hover{
padding-top:1.3em;
display:block;
background:url('images/button.png') center top no-repeat;
font-size: 18px;
color: #ffffff; font-weight: bold;
text-decoration: none;
height: 58px;
margin-bottom: 5px;
}
Here’s the button
Hope that helps.
Cheers!
Hey Ali !
I tried your code:
– at first it didn’t work at all, it seems a ” ; ” is missing when the menu is called:
%3$s’ ) ;
instead of
%3$s’ )
– when this ” ; ” is added, the page then shows up, but it display my main menu as a sidebar, instead of the specific menu I set up.
Sorry i’m a newbie, I must have missed something.
Yes, that indeed was missing., I have updated it. Once you see the menu, you can then change its placement and look and feel anyway you want. For that you must know css.
I don’t think I did something wrong, but it doesnt show my menu, it just actually prints out the code, and not the menu. Any solutions?
Make sure you add all php code inside php opening and closing tags like this: