Widgets – REST API Handbook | Developer.WordPress.org

Widgets

Schema

The schema defines all the fields that exist within a widget record. Any response from these endpoints can be expected to contain the fields below unless the `_filter` query parameter is used or the schema field only appears in a specific context.

Retrieve a Widget

Definition & Example Request

GET /wp/v2/widgets

Query this endpoint to retrieve a specific widget record.

$ curl https://example.com/wp-json/wp/v2/widgets

Arguments

context Scope under which the request is made; determines fields present in response.

Default: view

One of: view, embed, edit

sidebar The sidebar to return widgets for.

Create a Widget

Arguments

id Unique identifier for the widget.
id_base The type of the widget. Corresponds to ID in widget-types endpoint.
sidebar The sidebar the widget belongs to.

Required: 1

Default: wp_inactive_widgets

instance Instance settings of the widget, if supported.
form_data URL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

Definition

POST /wp/v2/widgets

Retrieve a Widget

Definition & Example Request

GET /wp/v2/widgets/<id>

Query this endpoint to retrieve a specific widget record.

$ curl https://example.com/wp-json/wp/v2/widgets/<id>

Arguments

context Scope under which the request is made; determines fields present in response.

Default: view

One of: view, embed, edit

Update a Widget

Arguments

id Unique identifier for the widget.
id_base The type of the widget. Corresponds to ID in widget-types endpoint.
sidebar The sidebar the widget belongs to.
instance Instance settings of the widget, if supported.
form_data URL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

Definition

POST /wp/v2/widgets/<id>

Example Request

Delete a Widget

Arguments

Definition

DELETE /wp/v2/widgets/<id>

Example Request

$ curl -X DELETE https://example.com/wp-json/wp/v2/widgets/<id>