Add menu item programmatically Drupal 6 I am trying to add a menu item to a custom menu programmatically in Drupal 6 and have almost gotten it but ran into a weird problem. I can add the item to the menu using the code: drupal_execute('menu_edit_item', $item_array, 'add', NULL, array('menu_name' =&gt; $menu_name));
drupal_flush_all_caches();
This somewhat works, but for the link to actually show up in the menu I have to either save the page twice, or save the page and clear the cache from Admin > Performance. Does anyone know why I need to flush the caches twice, or is there a better way to do this? Let me know if you need any more information, I included what I thought was relevant but I may have left something out.
To add menu items use hook_menu():


  This hook enables modules to register paths in order to define how URL
  requests are handled. Paths may be registered for URL handling only,
  or they can register a link to be placed in a menu (usually the
  Navigation menu).


example:

function YOUR_MODULE_NAME_menu() {
  $items['a/b/c'] = array(
    'title' =&gt; 'Example menu',
    'page callback' =&gt; 'example_callback',
    'access arguments' =&gt; array('access content'),
    'type' =&gt; MENU_NORMAL_ITEM,
    'menu_name' =&gt; 'your-custom-menu-name',
  );
  return $items;


}

To learn more about hooks see here