Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Wordpress Theme and Menus

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 304
    Comment on it

    Custom Menus will show in the header area at the top of your site. With some themes, you may have the option to create and display multiple custom menus in different places on your site, such as the footer or special sidebar areas.

    Creating a Custom Menu

    To create a custom menu, go to Appearance Menus in your dashboard.

    To create a new menu, click the create a new menu link, then just type in a Menu Name, and click the Create Menu button.

    After you create your first menu, you will notice that two new options appear to control the following:

    --->Auto add pages If checked, new pages will be added automatically when you create them.
    --->Theme locations Allows you to decide where you would like your custom menu to appear in your theme. By default, your menu will show up in the main navigation area of your theme. You can select a different location if your theme is capable of multiple menus.

    <?php
    wp_nav_menu( $nav_args );
    
    $nav_args = array(
        'theme_location'    => '',
        'menu'              => '',
        'container'         => false,
        'container_class'   => '',
        'container_id'      => '',
        'menu_class'        => 'menu',
        'menu_id'           => '',
        'echo'              => true,
        'fallback_cb'       => 'wp_page_menu',
        'before'            => '',
        'after'             => '',
        'link_before'       => '',
        'link_after'        => '',
        'items_wrap'        => '<ul id="%1$s" class="%2$s">%3$s</ul>',
        'depth'             => 0,
        'walker'            => ''
    );
    
    ?>
    

    Parameters:

    1. theme_location: The location in the theme to be used must be registered with register_nav_menu() in order to be selected by the user like primary navigation. It's default vale is none, it is optional and it takes string value.

    2. menu: The menu that is desired; accepts (matching in order) slug, id, name. It's default vale is none, it is optional and it takes string value.

    3. container: Whether to wrap the ul, and what to wrap it with. Allowed tags are div and nav. Use false for no container e.g. 'container' => false

    4. container_class: The class that is applied to the container.

    5. container_id: The ID that is applied to the container. It's default vale is none, it is optional and it takes string value.

    6. menu_class: The class that is applied to the ul element which encloses the menu items. Multiple classes can be separated with spaces. Formerly known as $wrap_class. It's optional and default value is menu.

    7. menu_id: The ID that is applied to the ul element which encloses the menu items. It is optional.

    8. echo: Whether to echo the menu or return it. For returning menu use '0'.

    9. fallback_cb: If the menu doesn't exist, the fallback function to use. Set to false for no fallback. Note: Passes $args to the custom function. It is optional and it's default value is 'wp_page_menu'.

    10. before: Output text before the of the link. It is optional and default value is none.

    11. after: Output text after the of the link. It is optional and default value is none.

    12. link_before: Output text before the link text. It is optional and default value is none.

    13. link_after: Output text after the link text. It is optional and default value is none.

    14. items_wrap: Evaluated as the format string argument of a sprintf() expression. The format string incorporates the other parameters by numbered token. %1$s is expanded to the value of the 'menu_id' parameter, %2$s is expanded to the value of the 'menu_class' parameter, and %3$s is expanded to the value of the list items. If a numbered token is omitted from the format string, the related parameter is omitted from the menu markup. Note: To exclude the items wrap (for instance, if the wrap is built into your theme), you still need to pass %3$s as the parameter. If you pass an empty string, your menu won't display at all. Default:

        %3$s

    15. depth: How many levels of the hierarchy are to be included where 0 means all. -1 displays links at any depth and arranges them in a single, flat list. It is optional and default value is 0.

    16. walker: Custom walker object to use (Note: You must pass an actual object to use, not a string). It It is optional.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: