How to Show Home Link In wp_nav_menu Default Fallback Function
6th Jan 2011 | Posted by reza | 18 CommentsWordPress wp_nav_menu function is really helpful to display a custom navigation menus in your wordpress theme. The custom menu can be set in the admin area, easily, with a drag-and-drop interface, similar to the way widgets are added to “sidebars”.
If you use wp_nav_menu() in your theme and the menu is not created yet in the admin area of WP, wp_nav_menu() will fallback to wp_page_menu() function, by default.
Ok, here’s the problem. You want to show home link, if the custom menu has not set yet, ie. the default fallback function which is wp_page_menu(), is called.
The wp_page_menu() doesn’t show home link, by default. The home link can be easily shown, via the function ‘show_home’ argument. But, this is different case, wp_page_menu() is used as fallback function. To show home link, needs different solution.
You can use the code below as the solution:
function my_page_menu_args( $args ) { $args['show_home'] = true; return $args; } add_filter( 'wp_page_menu_args', 'my_page_menu_args' );
Put the code in the theme function.php
Credit:
The code is taken from twenty ten theme
6 Comments to “How to Show Home Link In wp_nav_menu Default Fallback Function”
Add Comments (+)-
-
Wonderful, but I want to know how can I do for change the word “Home” for another. Sorry if I have mistakes in my english. I’m Salvadorean. Thanks a lot.
-
Use this code:
‘Blog’, ‘sort_column’ => ‘menu_order’ ) ); ?>
replace Blog with another text
-
-
Nice article.
Please visit http://www.wordpressstop.com for to get lot of stuff regarding to WordPress.
Keep Smiling
Trackbacks/Pingbacks
- How to Order Category by Most Recently Updated
- How to show the “home” link on wp_nav_menu default fallback function
- How to show the “home” link on wp_nav_menu default fallback function | WordPress Toolbag
- How to show the home link on wp_nav_menu
- Automatically Show Home Link On WP 3.0 Menus By Default
- How to show the “home” link on wp_nav_menu default fallback function | Wordpress Farm
- How to show the “home” link on wp_nav_menu default fallback function | Wordpress Farm
- 「ホーム」の文言を変更する | 1000g
- How to show the “home” link on wp_nav_menu default fallback function | The best Tutorials
- How to show the home link on wp_nav_menu - WPInsite
- How to show the “home” link on wp_nav_menu default fallback function | WP Tutorials | Summer Study
- How to Show The “home” Link on wp_nav_menu Default Fallback Function!
i want to know how to show categories their sub cats and few selected pages in header using wp_nav_menu
thanks