I would like to have this menu list created dynamically in the footer:
<a href="<?php bloginfo( 'url' ); ?>/">Home</a><br>
<a href="<?php bloginfo( 'url' ); ?>/about-us/">About Us</a><br>
<a href="<?php bloginfo( 'url' ); ?>/legal-services/">Our Legal Services:</a><br>
<a class="indent" href="<?php bloginfo( 'url' ); ?>/legal-services/commercial-law/">Commercial Law</a><br>
<a class="indent" href="<?php bloginfo( 'url' ); ?>/legal-services/concrete-law/">Concrete Law</a><br>
<a class="indent" href="<?php bloginfo( 'url' ); ?>/legal-services/general-business-law/">Business Law</a><br>
<a href="<?php bloginfo( 'url' ); ?>/contact-us/">Contact Us</a>
Including being able to recognise that a menu item is a child and have it indent (eg: class="indent"). Note: This can also be coded using unordered lists.. it doesn't matter to me, as it will be a vertical list.
It is exactly the same list of pages that are in the main navigation menu bar found in the header.php
Here is the code that I have for the main navigation in the header:
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<!-- button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar" --> <!-- not on mirage? -->
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<?php
$args = array(
'menu' => 'header-menu',
'menu_class' => 'nav navbar-nav navbar-right',
'container' => 'false'
);
wp_nav_menu( $args );
?>
</div><!--/.navbar-collapse -->
</div>
</nav >
And what I have in the function.php for the main navigation menu:
add_theme_support( 'menus' );
function register_theme_menus() {
register_nav_menus(
array (
'header-menu' => __( 'Header Menu' )
)
);
}
add_action( 'init', 'register_theme_menus' );
.
I just can't think of a way to duplicate / modify the above to do what I need in the footer. (Note this will be coded directly into footer.php, not created inside a widget.)
Can anyone offer any guidance?
EDIT:
I tried adding this code to the footer for a solution, but I must be doing something wrong, because I am getting the error message of: Menu "header-menu" not defined
<?php
// Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)
// This code based on wp_nav_menu's code to get Menu ID from menu slug
$menu_name = 'header-menu';
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
$menu_list = '<ul id="menu-' . $menu_name . '">';
foreach ( (array) $menu_items as $key => $menu_item ) {
$title = $menu_item->title;
$url = $menu_item->url;
$menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
}
$menu_list .= '</ul>';
} else {
$menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
}
// $menu_list now ready to output
echo $menu_list;
?>
Any help will be greatly appreciated!