wp_add_menu_item
Add a page or custom link to a WordPress navigation menu. Specify menu, target, title, and parent; use dry run to preview changes before applying.
Instructions
Add one item to a navigation menu (a site page, or a custom link).
menu is a menu id, or its EXACT name or slug (from wp_list_menus) - a reference
matching 0 or 2+ menus is refused and lists the available menus. Pass exactly one
target: page_id (from wp_find_page / wp_get_content) for a page on the site, or
url for a custom link. parent is the id of the menu item to nest under (0 =
top level); position is the item's menu_order (omit to append at the end).
DEFAULTS TO dry_run=true (returns a preview; writes nothing). Pass dry_run=false
to apply - the add is verified by reading the menu back. Requires the REST
transport. Prod writes require allow_prod=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | ||
| menu | Yes | ||
| title | Yes | ||
| parent | No | ||
| dry_run | No | ||
| install | Yes | ||
| page_id | No | ||
| position | No | ||
| allow_prod | No |