WordPress Main Menu – Hide ‘Home’ link on homepage only

I need to hide the “Home” link that’s generated from WordPress main menu on the homepage, and show it on the rest of the site.

I tried creating my own menu with no “Home” link and adding the “Home” link manually on the header.php file but it goes to the end of the menu and does not look like a pretty solution.

Read More

Any ideas? Using latest WordPress 3.2

Related posts

Leave a Reply

2 comments

  1. If you only want to hide it to the users, i suggest using the following CSS:

    body.home a[title="Home"] {
        display: none;
    }
    

    Explanation: WordPress generates several classes for the body tag. The home class is used to hide all links with the title Home on the homepage.

    Working Example (code taken from the default theme): http://jsfiddle.net/yJVyK/1/

    Note: The attribute selector does not work in IE6

  2. There is an another solution with PHP which more correct way in my opinion.

    add_filter( 'wp_nav_menu_objects', 'amc_filter_menu', 10, 2 );
    /**
     * Filters to remove Home Link on Front Page
     */
    function amc_filter_menu( $objects, $args ) {
    
        // Return Default Value if the Menu isn't Main Menu
      // Replace "Navigation_location" with your target location
        if ( 'Navigation_location' !== $args->theme_location ) {
            return $objects;
        }
    
        // Detect the Menu which equeal site URL
        foreach ( $objects as $key => $object ) :
    
            if ( get_site_url( null, '/' ) === $object->url && is_front_page() || get_site_url() === $object->url && is_front_page() ) :
                unset( $objects[ $key ] );
            endif;
    
        endforeach;
    
        // Return the menu objects
        return $objects;
    
    }
    
    
    

    Source