Add a menu item
wp_add_menu_itemAdd a published post, page, or custom link to a WordPress navigation menu at the end, optionally as a submenu item under a parent. Use it to build or extend menu structure.
Instructions
Add a published item to a navigation menu, at the end: a link to a post, page or entry of another post type when object_id is given, otherwise a custom link to url. Returns added and item_id. Each call adds a new item, also when one with the same target exists. A URL with a scheme WordPress does not allow in menus (javascript:, data:) is refused. Needs edit_theme_options and the right to assign this menu (assign_term), which a site can withhold for single menus. No undo point is recorded; wp_delete_menu_item removes an item.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"menu": "<menu>",
"title": "<title>"
},
"name": "wp_add_menu_item"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Target of a custom link, e.g. https://example.com/, mailto:, tel: or a relative path. Ignored when object_id is given. | |
| menu | Yes | Menu id, slug or name, as wp_list_menus returns them. | |
| title | Yes | Label shown in the menu. | |
| object | No | Post type of object_id, e.g. page or post. Default "page". Only used with object_id. | |
| parent | No | item_id of the parent item, as wp_get_menu returns it, for a submenu entry. Default 0 (top level). | |
| object_id | No | Post/page id for a content link; its URL follows the post. |