WordPress.org

Ready to get started?Download WordPress

Forums

TwentyTen Child: Remove Home Menu (7 posts)

  1. BionicSquid
    Member
    Posted 3 years ago #

    I've seen the advice to remove the Home menu from TwentyTen by changing show_home to false , as follows:

    /**
    * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
    *
    * To override this in a child theme, remove the filter and optionally add
    * your own function tied to the wp_page_menu_args filter hook.
    *
    * @since Twenty Ten 1.0
    */
    function twentyten_page_menu_args( $args ) {
    $args['show_home'] = false;
    return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );

    While this works sort of, I also have to delete the Home title from the homepage or else Home still appears, and this code only works in the parent functions.php file. I can't seem to get the code right in a functions.php child file - I get syntax and other errors using a variety of attempts including remove_filter etc.

    Can anyone point me in the right direction to enable a working functions.php child file that will turn off my Home menu while allowing me to still name the homepage Home?

    Thanks!

  2. ixe013
    Member
    Posted 3 years ago #

    I'm having the same problem. The comment in the original theme does not make any sense to me. Aren't child themes functions loaded before the parent ? If so, there will not be a filter to remove...

    The only working answer is to edit the parent functions.php file to set show_home to false.

  3. chinmoy
    Member
    Posted 3 years ago #

    what is name of child theme?

    If it is 2010 weaver then goto 2010functions.php file and put false(line 272).

    function twentyten_page_menu_args( $args ) {
    	$args['show_home'] = false;
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );
  4. klebba
    Member
    Posted 3 years ago #

    "The way to get around this is to use the after_setup_theme action hook. This action is called immediately after both functions.php files are loaded."

    From:

    http://ottopress.com/2010/wordpress-protip-child-themes/

  5. FMaz008
    Member
    Posted 3 years ago #

    If you don't understand what Chinmoy29 ans klebba are saying, here's the simple way to do it for a Child Theme based on TwentyTen:

    1. Create a functions.php file in your root childtheme folder
    2. Put this content in it:
    <?php

    /* Retirer le lien "HOME" du menu de navigation */
    function removeHome( $args ) {
    remove_filter('wp_page_menu_args', 'twentyten_page_menu_args');
    $args['show_home'] = false;
    return $args;
    }
    add_action( 'after_setup_theme', 'removeHome' );

  6. acar.soner
    Member
    Posted 2 years ago #

    This worked great, ty!

  7. lucasdegen
    Member
    Posted 2 years ago #

    FMaz008, thanks, this works indeed

    /* Retirer le lien "HOME" du menu de navigation */
    function removeHome( $args ) {
    remove_filter('wp_page_menu_args', 'twentyten_page_menu_args');
    $args['show_home'] = false;
    return $args;
    }
    add_action( 'after_setup_theme', 'removeHome' );

Topic Closed

This topic has been closed to new replies.

About this Topic