I am making an attempt to get a menu objects created from wordpress admin panel.
To do that I adopted the directions codex:
http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items
// Get the nav menu primarily based on $menu_name (similar as 'theme_location' or 'menu' arg to wp_nav_menu)
// This code primarily based on wp_nav_menu's code to get Menu ID from menu slug
$menu_name = 'custom_menu_slug';
if ( ( $places = get_nav_menu_locations() ) && isset( $places[ $menu_name ] ) ) {
$menu = wp_get_nav_menu_object( $places[ $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 outlined.</li></ul>';
}
// $menu_list now able to output
echo $menu_list;
However I get all the time the error: Menu “cs-1-language” not outlined.
I attempted with the title and the slug and completely different menus however I all the time discover that error.
Does anybody know what I am doing improper or if there may be one other approach to record the objects of a menu?
Thanks!