Title: Programmatically create a menu item
Last modified: August 22, 2016

---

# Programmatically create a menu item

 *  [UKJS](https://wordpress.org/support/users/ukjs/)
 * (@ukjs)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/programmatically-create-a-menu-item/)
 * Hi Again,
 * I’m trying to create menu items programmatically, and it seems to be working,
   Via an install.php file I’m able to create a new menu then add menu items. The
   problem is that they appear as ‘custom’ not ‘page’ and they display in the menu,
   but don’t work as links
 * I have posted the code below. I have also created a page maually in wp, then 
   compared the 2 menu items in the posts and postsmeta tables, and they look identical.
 * Does anyone have any idea why this is happening?
 * Many thanks
 * John
 *     ```
       // add pages to the new menu
           wp_update_nav_menu_item($menu_id, 0, array(
       		'menu-item-type' => 'post-type',
       		'menu-item-object' => 'page',
       		'menu-item-author' => 1,
       		'menu-item-attr-title' => '',
       		'menu-item-status' => 'publish',
       		'menu-item-title' =>  'Home',
       		'menu-item-object-id' => 1,
       		'menu-item-name' => 7,
               //'menu-item-parent-id' => 0,
       		//'menu-item-position' => 0,
       		'menu-item-db-id' => 7,
       		//'menu-item-description' => '',
       		//'menu-item-target' => '',
       		//'menu-item-classes' => '',
       		//'menu-item-xfn' => '',
       		));
       ```
   

The topic ‘Programmatically create a menu item’ is closed to new replies.

## Tags

 * [menu](https://wordpress.org/support/topic-tag/menu/)

 * 0 replies
 * 1 participant
 * Last reply from: [UKJS](https://wordpress.org/support/users/ukjs/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/programmatically-create-a-menu-item/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
