WordPress.org

Ready to get started?Download WordPress

Forums

Why "Your theme supports 1 menu"? (1 post)

  1. mirgcire
    Member
    Posted 11 months ago #

    This custom menu configuration process has been vexing me for several days. Now that I feel like I got my head around it, I think there might actually be a bug. Or at least a disconcertingly, unexpected feature.

    For this project I am using a twentytwelve child theme. Apparently, the twentytwelve theme defines a single menu type. But I am not exactly sure what that means. (How can something in wordpress NOT be configurable?)

    Here is how I set up some custom menus.

    First I modified function.php in my child theme to support more menus:

    function register_my_menus() {
      register_nav_menus(
        array(
          'header-menu' => __( 'Header Menu' ),
          'no-menu' => __( 'No Menu' ),
          'right-sidebar', __('Lesson Menu')
        )
      );
    }
    add_action( 'init', 'register_my_menus' );

    I use no-menu on pages were a menu does not make sense, and header menu on pages that I want a want a fixed set of menu items.

    My next step was to create page templates that support these menu types.

    I added "register-page.php" and "header-nomenu.php" to the child theme. The only thing different about register-page.php is that it calls out header-nomenu.php instead of header.php.

    get_header('nomenu')

    In header-menu.php I replaced the internals of the <nav> element with

    <?php wp_nav_menu( array( 'theme_location' => 'no-menu', 'menu_class' => 'nav-menu' ) ); ?>

    Then, in the "Edit Menus" tab of the Admin-dashboard Appearances > Menu I created a "No Menu" menu with no items. And "Header Menu" with specific content.

    However, when I select the "Menu Locations" tab on the same page it still says "Your theme supports 1 menu". I am disappointed because I thought that if I added more menus with register_nav_menus, they would populate the "Menu Locations" page.

Reply

You must log in to post.

About this Topic