Wordpress "Home" link
I'm working on a Sandbox based Wordpress theme and I would like to add a home link as a first item in the navigation. I know I should change the function in "sandbox_globalnav" in the functions.php file, which is:
// Produces a list of pages in the header without whitespace
function sandbox_globalnav() {
if ( $menu = str_replace( 开发者_Go百科array( "\r", "\n", "\t" ), '', wp_list_pages('title_li=&sort_column=menu_order&echo=0') ) )
$menu = '<ul>' . $menu . '</ul>';
$menu = '<div id="menu">' . $menu . "</div>\n";
echo apply_filters( 'globalnav_menu', $menu ); // Filter to override default globalnav: globalnav_menu
}
However, my PHP skills are really basic and I'm not sure where I should override this.
Thanks!
<li>
<a rel="<?php _e("bookmark"); ?>" title="<?php _e("Home"); ?>" href="<?php bloginfo('url'); ?>">
<?php _e("Home"); ?>
</a>
</li>
Put this before wp_list_pages,this must be first li item.
user303832 is right but this is more like it.,
<li <?php if(is_home()) { ?>class="current_page_item"<?php } ?>>
<a rel="<?php _e("bookmark"); ?>" title="<?php _e("Home"); ?>" href="<?php bloginfo('url'); ?>">
<?php _e("Home"); ?>
</a>
</li>
I use the "current_page_item" class on HOME to if i have a style applied to current page "link".
Upgrade to WordPress 3.0 and you'll find a built in menu creator. No PHP knowledge needed. This should work in modifying the navigation for most themes.
精彩评论