2
votes

I am currently trying to add specific menus to the page for HTML5 blank theme. I created new positions via the following code in functions.php

// Register HTML5 Blank Navigation
function register_html5_menu()
{
    register_nav_menus(array( // Using array to specify more menus if needed
        'header-menu' => __('Header Menu', 'html5blank'), // Main Navigation
        'sidebar-menu' => __('Sidebar Menu', 'html5blank'), // Sidebar Navigation
        'motor-vehicles-menu' => __('Motor vehicles menu', 'html5blank'), 
        'salvage-menu' => __('Salvage Menu', 'html5blank'),
        'general-goods-menu' => __('General goods Menu', 'html5blank'),
        'industrial-menu' => __('Industrial Menu', 'html5blank'), // Extra Navigation if needed (duplicate as many as you need!)
        'about-menu-menu' => __('About Menu', 'html5blank') // Extra Navigation if needed (duplicate as many as you need!)
    ));
}

I have then went it the admin via menu section and created the menu for salvage position

enter image description here

I then go to my theme and try to present the menu using the following:

<?php html5blank_nav( array( 'theme_location' => 'salvage-menu') ); ?>

I am not sure how exactly how to make this work. Any help would be great.

Thanks

2

2 Answers

2
votes

That's not how you show your menu in your files.

You've registered them, and this works (you can see them in admin), but you need wp_nav_menu() function to display the menu. For instance:

<?php wp_nav_menu( array( 'theme_location' => 'salvage-menu', 'container' => false, 'menu_id' => 'salvage-menu', 'menu_class' => '', 'fallback_cb' => false ) );?>

Hope this helps :)

0
votes

There are two steps for creating a menu/widget/plugin.

  1. Writing functionality in functions.php.
  2. Register function to display it in admin panel.

Step 1: Writing functionality in functions.php.

<?php
wp_nav_menu(array(
    'theme_location' => 'salvage-menu',
    'container' => false,
    'menu_id' => 'salvage-menu',
    'menu_class' => '',
    'fallback_cb' => false
));
?>

Step 2: Register and call your newly created function from theme.

<?php html5blank_nav( array( 'theme_location' => 'salvage-menu') ); ?>