Menus seem to generate the most questions and since there have been many threads in the last couple of days, i have decided to lump all the stuff I have together in 1 place. All the functions go in the functions.php file of your child folder! The style rules i have included go in your child's style.css. If it is deemed worthy, perhaps it can get stickied.
If you see any code errors, point them out. But if you need support or are having issues, I think creating your own thread would be best. That way, future people won't need to wade through everything to get to updates to this post. (not that significant wading isn't required for this post... it is long!).
Things I am going to cover:
1. Moving the menu
2. Adding a Home link
3. using a single wordpress 3.0 menu
4. filter your 3.0 menu's arguments
5. use more than one 3.0 menu
6. css styling
7. filtering away superfish dropdowns
8. modifying superfish to show little arrows to indicate a sub menu
edit Jan 07, 2012:
Removing instructions for version 0.9.7.4 as thematic is at 0.9.7.7 in the WP repo and I advise you to use 0.9.8 which is available at:
http://developing.thematic4you.com/thematic-development-release/
And lets begin...
1. Moving the Menu above the header
moving the default menu is a matter of removing the respsonible function (in this case thematic_access() ) from its current position and adding it back to a different hook.
// Remove the standard Thematic menu
function remove_menu() {
remove_action('thematic_header','thematic_access',9);
}
add_action('init', 'remove_menu');
// Moving the thematic menu above the header
add_action('thematic_aboveheader','thematic_access');
you could also re-write the whole access function, but i don't do this often anymore, so i will refer you to Ian's post instead to attempt to keep this thread under control
http://themeshaper.com/wordpress-menu-tricks/
2. Adding a Home Link
Switching the default wp_list_pages() menu to wp_page_menu so that a home link can be added. because this changed between the old and new versions of thematic i will do it both ways.
Thematic 0.9.7.4+
When filtering wp_page_menu_args, the echo parameter must now be set to FALSE. Chris explains why here:
http://developing.thematic4you.com/2010/04/breaking-things-to-fix-others/
just know that it has to do w/ adding the sf-menu class to the ul that contains the menu. w/o that sf-menu class you will probably notice that your menu loses all its default style.
// Adds a home link to your menu in Thematic 0.9.7.4
function childtheme_menu_args($args) {
$args = array(
'show_home' => 'Home',
'sort_column' => 'menu_order',
'menu_class' => 'menu',
'echo' => false
);
return $args;
}
add_filter('wp_page_menu_args','childtheme_menu_args');
Thematic 0.9.7.7+
You can also add a home link (or anything) to your custom menu by filtering wp_nav_menu_items() as instructed here:
http://wpfirstaid.com/2010/10/extend-the-wordpress-menu/
// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items) {
$current = is_home() ? 'current-menu-item' : '';
$homelink = '<li class="home menu-item'.$current.'"><a href="' . home_url( '/' ) . '">' . __('Home') . '</a>';
$items = $homelink . $items;
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
you don't really need this for 'home' any more. As of WP 3.3 you can add a Home Link directly from your WP custom menu (it is under Pages), but it is still very useful for adding anything to your menu.
3. Wordpress 3.0 Menus for Thematic
My favorite resource on 3.0 menus is:
http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus
If you are using Thematic 0.9.8, then you don't need to do any coding in order to use WP's 3.0-style menu. You only need to create a menu and set it in the 'Primary' position. Thematic will take care of the rest.
http://developing.thematic4you.com/thematic-development-release/
some older posts and tutorials will mention needing to use
add_theme_support( 'nav-menus');
//OR
add_theme_support( 'menus' );
in order to activate menus. but this is now NOT advised.
http://forums.themeshaper.com/topic/add_theme_supportmenus
the following is all you need to get a single 3.0 menu to replace the default thematic #access menu.
Enable 1 wordpress 3.0 Menu in Thematic 0.9.7.7
if you are still using 0.9.7.7 (and WHY? when so many bugs have been fixed in 0.9.8?) then you might need to switch the thematic access to use the 3.0-style menus.
// change Thematic #access menu for a Wordpress 3.0 menu
function child_access_menu() {
$menu_sys = 'wp_nav_menu';
return $menu_sys;
}
add_filter('thematic_menu_type', 'child_access_menu');