WordPress.org

Ready to get started?Download WordPress

Forums

Eliminate Drop Down Menu in Twenty Twelve (10 posts)

  1. midlife mama
    Member
    Posted 1 year ago #

    Still slowly, slowly working on my Child Theme for Twenty Twelve. Today I'm trying to eliminate the drop down menu. (I have so many articles/pages on my site that when a visitor uses the drop down menu, it becomes overwhelming and I'd like to get rid of it.)

    Can anyone help?

  2. Andrew
    Forum Moderator
    Posted 1 year ago #

    Try setting up a Custom Menu in the dashboard (Appearances > Menus) so you can specify what you want in there.

  3. midlife mama
    Member
    Posted 1 year ago #

    Hmmmm. Nothing seems to be unusual about my custom menu. I mean, it's only top-level pages.

    Any other tips?

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    have you setup and activated the custom menu?

    without custom menu, to show only top level page sin teh menu, add this to functions.php in your child theme:

    function twentytwelve_child_page_menu_args( $args ) {
    	$args['depth'] = 1;
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentytwelve_child_page_menu_args', 20 );

    http://codex.wordpress.org/Function_Reference/wp_page_menu
    the 'depth' parameter is not described there, but seems to work.

  5. midlife mama
    Member
    Posted 1 year ago #

    Thank you! It worked!
    Although it took me a minute to figure out that this code needed to go INSIDE the <?php and ?> (I only mention it for other newbies like myself.)

  6. midlife mama
    Member
    Posted 1 year ago #

    Although it worked for what I wanted (i.e. stop the drop down menu), I think I might have placed this code in the wrong section of functions.php as where I placed it somehow messed up my media file (I couldn't add any media to post/pages and every time I tried to update a post/page, the screen went white).

    Could you tell me specifically where the code should go inside the functions.php file??

    THANK YOU!

  7. alchymyth
    Forum Moderator
    Posted 1 year ago #

    where the code should go inside the functions.php file?

    anywhere - obviously without breaking the php syntax.

    every time I tried to update a post/page, the screen went white

    possibly enable DEBUG to get any warnings or error messages - http://codex.wordpress.org/Debugging_in_WordPress

  8. midlife mama
    Member
    Posted 1 year ago #

    Hmmmm. I did place the code in the right spot, and as I've written before, it does what I want--eliminate the pull down menu. So I can only assume that I need to enable DEBUG. Unfortunately, the codex is a bit over my head.

    Any step by step advice? Or should I try a plug in as recommended at the end of the codex?

  9. midlife mama
    Member
    Posted 1 year ago #

    (Oops. Posted this in a new thread. Sorry didn't realize my mistake. Won't happen again.)

    Does this code in functions.php look correct? Thinking maybe somehow I'm writing it wrong.

    <?php
    /* Functions file for the Child of Twenty Twelve child theme */
    
    function mychildtheme_setup() {
    
    	// This theme uses wp_nav_menu() in one location.
    	register_nav_menu( 'secondary', __( 'Footer Menu', 'twentytwelve' ) );
    }
    add_action( 'after_setup_theme', 'mychildtheme_setup', 11 );
    
    function twentytwelve_child_page_menu_args( $args ) {
    	$args['depth'] = 1;
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentytwelve_child_page_menu_args', 20 );
    
    ?>
  10. midlife mama
    Member
    Posted 1 year ago #

    After sifting through this forum, I think I found the answer to my problem. Another poster suggested adding 'depth' => 1 to header.php file to disable drop-down menu. I put the code on this line:
    <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'depth' => 1 ) ); ?>

    It seems to work.

Topic Closed

This topic has been closed to new replies.

About this Topic