Add Widget
Adds a widget to a widget area, at an optional position (0 is the top; leave it out to add at the bottom). Give either block_markup, saved as a block widget and checked first to contain at least one block this site has, or a classic widget type from mosmcp/widget-list-types with its settings; settings left out take the defaults the widget's own form uses. The widget's own validation runs exactly as on the Widgets screen, and the result is read back, so the answer reports anything WordPress changed while saving. The new widget shows on every page that displays the area. Refused with an explanation on a block theme, which has no widget areas.
Also known as: add a widget, add to sidebar, add to footer, new widget, custom html widget, put a widget in the sidebar.
| Property | Value |
|---|---|
| Ability slug | mosmcp/widget-add |
| Wire tool name | mosmcp__widget-add |
| Category | Widgets & Sidebars (mosmcp-widgets) |
| Plan | Free |
Required access
| Requirement | Value |
|---|---|
| Capability | edit_theme_options |
| Minimum default role | Administrator (Shop manager too when WooCommerce is active) |
| Annotations | readOnly: false · destructive: false · idempotent: false · openWorld: false |
Input schema
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| area | string | Yes | — | The area to add to: its ID ("sidebar-1") or name ("Footer"), from mosmcp/widget-list-areas. |
| position | integer (min 0) | — | Optional 0-based position in the area: 0 puts it at the top. Leave out to add it at the bottom. | |
| block_markup | string | — | Block markup for a block widget, for example <!-- wp:heading --><h2>Opening hours</h2><!-- /wp:heading --><!-- wp:paragraph --><p>Monday to Friday, 9 to 5.</p><!-- /wp:paragraph -->. Leave out when adding a classic widget type. HTML is saved the way the WordPress editor saves it: a user with the unfiltered_html capability can save any markup, including forms, scripts and styles, and markup a user is not allowed to save is refused with the reason rather than silently removed. Backslashes are kept. | |
| type | string | — | A classic widget type by id_base, such as "custom_html", "text", "recent-posts" or "nav_menu", from mosmcp/widget-list-types. Leave out when passing block_markup. | |
| settings | object | — | Settings for a classic widget type, by name, for example {"title": "Latest news", "number": 5}. mosmcp/widget-list-types lists each type's settings. HTML in a Custom HTML or Text widget follows the same rule as block_markup. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| widget_id | string | Yes | |
| area | string | Yes | Area the widget is in now. |
| position | integer | Yes | 0-based position in that area now. |
| widget | object | Yes | |
| widget.widget_id | string | Yes | The widget ID, for example "block-3" or "text-2". |
| widget.id_base | string | Yes | The widget type, for example "block", "text" or "custom_html". |
| widget.type_name | string | ||
| widget.area | string | Area ID the widget is in. | |
| widget.area_name | string | ||
| widget.area_status | string (one of active, inactive, unregistered) |
"active" when the area is shown on the site, "inactive" for the inactive-widgets bin, "unregistered" for an area the active theme does not register. | |
| widget.position | integer | 0-based position in its area; 0 is the top. | |
| widget.title | string | ||
| widget.summary | string | One line describing what the widget shows. Secrets are never included. | |
| widget.is_block_widget | boolean | ||
| widget.blocks | string[] | Block types in a block widget. | |
| widget.settings_editable | boolean | False when the widget's type is missing or not built with the standard widget API; it can still be moved or deleted. | |
| widget.settings | object | All the widget's settings, with secret-looking values masked. For a block widget, its content setting holds the block markup. | |
| widget.masked_settings | string[] | Names of settings whose values are masked. | |
| widget.block_markup | string | The block markup of a block widget. Empty for other widgets. | |
| area_widgets | string[] | Every widget in that area, in display order. | |
| warnings | object[] | Yes | Non-fatal issues encountered while running. |
| warnings[].code | string | ||
| warnings[].message | string | ||
| warnings[].context | string | ||
| notes | string[] |
| << Previous | Next >> |
|---|---|
| Update Navigation Link | Delete Widget |
For more information about the Secure MCP Server for WordPress plugin, explore the following resources:
Product Overview | Pricing | Try for Free | Documentation
If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.