How to Show Home Link In wp_nav_menu Default Fallback Function

WordPress 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”.

How to Show Home Link In wp_nav_menu Default Fallback Function

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 (+)

  1. i want to know how to show categories their sub cats and few selected pages in header using wp_nav_menu
    thanks

  2. Julio says:

    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.

  3. Prasad says:

    Nice article.

    http://www.wordpressstop.com to get lot of stuff regarding to WordPress.

  4. Prasad says:

    Nice article.

    Please visit http://www.wordpressstop.com for to get lot of stuff regarding to WordPress.

    Keep Smiling

Trackbacks/Pingbacks

  1. How to Order Category by Most Recently Updated
  2. How to show the “home” link on wp_nav_menu default fallback function
  3. How to show the “home” link on wp_nav_menu default fallback function | WordPress Toolbag
  4. How to show the home link on wp_nav_menu
  5. Automatically Show Home Link On WP 3.0 Menus By Default
  6. How to show the “home” link on wp_nav_menu default fallback function | Wordpress Farm
  7. How to show the “home” link on wp_nav_menu default fallback function | Wordpress Farm
  8. 「ホーム」の文言を変更する | 1000g
  9. How to show the “home” link on wp_nav_menu default fallback function | The best Tutorials
  10. How to show the home link on wp_nav_menu - WPInsite
  11. How to show the “home” link on wp_nav_menu default fallback function | WP Tutorials | Summer Study
  12. How to Show The “home” Link on wp_nav_menu Default Fallback Function!

Leave a Reply

 

Amazingly Beautiful WordPress Themes