Enabling 3.0 Menu Support
If you have WordPress 3.0 installed, but your theme is older and doesn’t support it, here’s how to make those fancy awesome new menus work in your theme…
- First, sign into the admin. This is located at www.yoursitehere.com/wp-admin
- Next, click on the Appearance Section.
- Click Editor
- Click Theme Functions (functions.php) on the right.
- Scroll down to the bottom of the file, and just before the closing tag “?>” copy this code:
function navMenusEnable(){ add_theme_support( 'menus' ); } add_action( 'after_setup_theme', 'navMenusEnable' );
This will make sure your theme can use the menu system new in WordPress 3.0.
- Click Update File
Retrofit Your Theme Files
- While in this screen click Header (header.php) on the right
- Find the line (in almost all themes) where it looks like this:
<?php wp_list_pages('title_li='); ?>
It may not match this exactly, but you will see the wp_list_pages() function in there, with some random stuff in between the (). That is fine, don’t worry. All you do is place 2 slashes in front of the wp_list_pages() portion, like this:
<?php //wp_list_pages('title_li='); ?>
This disables the old pages menu. You do this with slashes so that if anything goes wrong or you don’t like the new feature, you can always just go back and take the slashes out, and it will work like normal again.
- Just above the line you just added slashes to, add this code:
<?php wp_nav_menu( 'sort_column=menu_order' ); ?>
- Click Update File
The final code in the header should look like this:
<?php wp_nav_menu( 'sort_column=menu_order' ); ?> <?php //wp_list_pages('title_li='); ?>
You should now be able to go to Appearance then Menus and create custom menus that will automatically show up in your site. Cool huh?
WordPress 3.0 rocks for this and a ton of other reasons. Let me know if you’d like to see more on WordPress programming. I enjoy it, and I hope I can help you enjoy it too.
