mmp460

Class Information, Notes and code samples for MMP 460

slack

Specifying Menu Code

You have the option to specify the HTML elements, classes and ids that WordPress will use to create the menu(s).

MENU ACTIVATION

To activate the menu function in the dashboard register menus in functions.php:

    <?php
    register_nav_menu( 'your-menu-handle', 'Your Menu label');
    ?>

The menu label is what you will see as the menu location in the dashboard. To register multiple menus read here.

THEME INTEGRATION

To control the code of your menu you have the option to specify the container element (for example nav or div), its class, id and other parameters. For example this code could replace the static html menu:

    <?php
    $main_menu = array(
    'theme_location' => 'main-menu',  /* this is the menu handle */
    'container' => 'nav',
    'container_class' => 'menu-nav',
    'container_id' => 'main-nav',
    'depth' => 1                                 /* how many level deep the navigation should go  */
    );
    ?>

    <?php wp_nav_menu( $menu_name ); ?>

Click for a full list of parameters and their default values.