More Questions Than Answers

Dan Atrill's blog site

WordPress 3.0 menus

Wordpress 3.0 menu settings

I’ve been working with several websites that have upgraded to WordPress 3.o and I’m loving the menu options that you get now. As with every bit of software, what is difficult in one version quickly improves in subsequent versions. I started using Flash when it was at version 3 and though I still use Flash CS3, it’s a much improved program. And so with WordPress. There’s a whole raft of improvements that you can read about at the WordPress Codex Version3.0 page.

The questions people always ask are about making navigation that highlights when on a particular page, and making navigation for pages that have been created. So in WordPress 3.0 this is possible, using a combination of methods.

This article at Think Vitamin ( http://thinkvitamin.com/dev/getting-started-with-wordpress-custom-menus/ ) goes into a lot of detail, but I’ll go into a little of what I know here.

With WordPress 3.0 it’s possible to create a theme which is menu-enabled. This can be as simple as inserting something like the following in the functions.php script file for the theme:

add_action( 'init', 'register_my_menus' );
   function register_my_menus() {
         register_nav_menus(
            array(
                 'menu-1' => __( 'Menu 1' ),
                 'menu-2' => __( 'Menu 2' ),
                 'menu-3' => __( 'Menu 3' )
           )
      );
}

Within the header, or wherever you want to place the menu add something like:

<?php
     wp_nav_menu( array( 'theme_location' => 'menu-1' ) );
?>

This refers back to the menu you’re going to create in WordPress.

Wordpress 3.0 Custom Menu Widget

Finally, in WordPress, goto Appearance > Menus and create your menu. Some advantages also lie in using the new Custom Menu widget from Appearances > Widget whereby it’s possible to create menu groups and hierarchies. And with some CMS – specifically using the current-menu-item and current-page-item classes, you can start contextual formatting so the user knows which page they’re on from the selected menu item.

There’s a lot more to WordPress 3.0 I’m still exploring, but this has been an exciting development.

Don’t forget to read the article at http://thinkvitamin.com/dev/getting-started-with-wordpress-custom-menus/ as well!

Sun, July 25 2010 » software, Web developing, Wordpress

Leave a Reply

*