add_filter( 'wp_nav_menu_items', 'add_home_link', 10, 2 );
function add_home_link($items, $args) {
if (is_front_page())
$class = 'class="current_page_item"';
else
$class = '';
$homeMenuItem =
'<li ' . $class . '>' .
$args->before .
'<a href="' . home_url( '/' ) . '" title="Home">' .
$args->link_before . 'Home' . $args->link_after .
'</a>' .
$args->after .
'</li>';
$items = $homeMenuItem . $items;
return $items;
}
Then call the navigation menu in header.php like this:
<?php
if(function_exists('wp_nav_menu')):
wp_nav_menu(
array(
'menu' =>'primary_nav',
'container'=>'',
'depth' => 1,
'menu_id' => 'menu' )
);
else:
?>
<ul id="menu">
<li><a href="<?php bloginfo('url'); ?>" title="Home">Home</
a></li>
<?php wp_list_pages('title_li=&depth=1'); ?>
</ul>
<?php
endif;
?>
No comments:
Post a Comment