Menus are a new big thing in the upcoming release of WordPress 3.0 and most of the theme builders will have to add at least some minor support in their themes for menus to work. Not so long time ago we tested one of the WordPress nightly builds and we had some trouble with our theme. It was about time to address these issues and see how much work will be required to add support for menus to our theme. It turned out that the work was minimal and really simple. We did miss few things that would be nice to have. Read on to see what needs to be done in your theme to support menus.
Menu structure on www.twm-kd.com is not that complicated, we have only two buttons on our front page, three if you are one of the three wise men. We replicated this structure in menu editor, which has matured since the last version we tested.
Three simple buttons and we are basically done. Then we had to change our functions.php file in our theme directory, we simply added one line to the file inside the first php block:
add_theme_support('nav-menus');
Then we had to change the header.php where the menus are loading. Previously the relevant part of header file looked like this:
<div id="menu"> <ul> <li class="page_item"><a href="<?php echo get_option('home'); ?>/">Home</a></li> <li class="page_item"><a href="<?php echo admin_url();?>">Admin</a></li> </ul> </div>
And now, after the change, it looks like this:
<?php wp_nav_menu(); ?>
Yes, we are down to a single line, great isn’t it? Menus did not look like we wanted them, but that was a minor change to the style.css. This is how our menu used to look like with WordPress 2.9.x:
And this is how it looks like now after the change:
Both versions now look the same and the effort was minimal. Experienced developers should be able to make a transition in no time. We did notice one thing, our Admin button was shown only when a user with admin privileges was logged in, menus could also support this. It is not something that would be hard to implement or add, privilege based menus would be nice. We are still unable to add a non functional, label only, items to the menu that would serve as parent items for sub-menus. This could also be achieved if we could include other menus as sub menus.





[...] This post was mentioned on Twitter by David Klasinc. David Klasinc said: Using menus in your theme for WordPress 3.0 a quick tutorial: http://bit.ly/cf23fx #wordpress #menus #3.0 [...]
[...] Using menus in WordPress 3.0 (twm-kd.com) var a2a_config = a2a_config || {}; a2a_config.linkname="10 WordPress Traffic Builder Plugins That Work"; a2a_config.linkurl="http://susandaniels.biz/lifestyles/2010/05/16/10-wordpress-traffic-builder-plugins-that-work/"; [...]
[...] Using menus in WordPress 3.0 (twm-kd.com) June 14, 2010 // // Technology // No Comments // Tags: Neutral build, Plugins, Publishers, Templates, Tools, User interface, WordPress Find out more about advertising here! [...]