Add a menu item
add_menu_itemAdd entries to WordPress navigation menus, linking to posts, pages, terms, or custom URLs, with support for submenus and ordering.
Instructions
Add an entry to a navigation menu. It can point at a post, page or custom post type (object_id + object), a taxonomy term, or an arbitrary URL. Use parent to nest it under another item and menu_order to position it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | Target URL. Required for type "custom". | |
| xfn | No | XFN relationship value for the link. | |
| type | No | custom: an arbitrary URL. post_type: link to a post/page/CPT (set object + object_id). taxonomy: link to a term. post_type_archive: link to a CPT archive. | custom |
| title | Yes | Link label. | |
| object | No | For post_type: the post type slug ("page"). For taxonomy: the taxonomy slug ("category"). | |
| parent | No | Menu item ID to nest under, creating a submenu. | |
| target | No | _blank opens in a new tab. | |
| classes | No | Extra CSS classes on the link. | |
| menu_id | Yes | Menu to add to. | |
| site_id | No | Which configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids. | |
| object_id | No | ID of the post or term being linked to. | |
| attr_title | No | The link's title attribute. | |
| menu_order | No | Position within the menu. Lower numbers come first. | |
| description | No | Item description, shown by themes that support it. |