title: How to generate menu with sub items?
body: <p>Im trying to generate a menu, in wordpress, with sub items. My current attempts have been something like this,</p>
  
  <pre><code>$mainmenu       = wp_create_nav_menu( 'main' );
  $submenu = array('menu-item-type' =&gt; 'custom',
                  'menu-item-url' =&gt; '/',
                  'menu-item-title' =&gt; 'sub-menu' );
  
  wp_update_nav_menu_item( $mainmenu, 0, $submenu );
  
  var_dump(wp_get_nav_menus());
  </code></pre>
  
  <p>The <code>var_dump()</code> shows the mainmenu but has a count of 0 where I expected 1 sub item.
  What is the correct approach for this?</p>