Add a widget
create_widgetAdd a widget to a sidebar, specifying the widget type and instance settings, including block content for modern widgets.
Instructions
Add a widget to a sidebar. id_base names the widget type (block, text, nav_menu, search, categories, recent-posts…). For the modern "block" widget, put block markup in instance.content — that is how the block-based widget editor stores everything.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id_base | Yes | Widget type: "block" for a block widget, or a classic type such as "text", "nav_menu", "search", "categories", "recent-posts". | |
| sidebar | Yes | Target sidebar id, e.g. "sidebar-1". See list_sidebars. | |
| 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. | |
| instance | No | Widget settings. For id_base "block", use {"content": "<!-- wp:paragraph --><p>Hi</p><!-- /wp:paragraph -->"}. For "nav_menu", {"title": "Menu", "nav_menu": 12}. | |
| position | No | Index within the sidebar. Appended if omitted. |