
The new menu system in wordpress, while not perfect (yet), is a huge step in the right direction. I have had to update many old themes to support this feature, and as most of my theming is down with thematic, I finally got a standard block of code together to add to a functions.php file of a child theme to add theme support for menus and add them to the theme. Here is the code, all you do is add it to your functions file and then you can manage menus thorugh the new menu page in your pw dashboard! Enjoy!
// declare that our theme supports wp_nav_menu()
add_theme_support( 'menus' );
// Register the a new menu for the theme called "Primary Menu"
function register_primary_menu() {
register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
}
add_action( 'init', 'register_primary_menu' );
// Remove the standard Thematic menu
function remove_menu() {
remove_action('thematic_header','thematic_access',9);
}
add_action('init', 'remove_menu');
// Create the new wp_nav_menu called "Primary Menu" in theme
function new_access() { ?>
<div id="access">
<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
<?php /* Navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */
wp_nav_menu( array(
'theme_location' => 'primary-menu', // define this as being the previously registered "Primary Menu"
'menu_class' => 'sf-menu', // assign the sf-menu class to the menu ul so that superfish works
'container_id' => 'menu' // assign the menu id to the menu container div so to keep it compatible with the Thematic menu styling
));
?>
</div><!-- #access -->
<?php
}
add_action('thematic_header','new_access',9);















2 Comments
When no primary menu is selected in the Appearance > Menus screen, will the old-type page menus be the default?
This looks like a great solution, but I’ll be applying in a multisite situation with legacy menus that need to be supported.
TIA!
Just read the commented code. I’ll give it a try!