`/wp/v2/widgets`

Namespace: wp/v2
Route: /wp/v2/widgets

Routes

  • Collection: /wp/v2/widgets
  • Single: /wp/v2/widgets/{id}

HTTP Methods

Collection methods: GET, POST

Single methods: GET, POST, PUT, PATCH, DELETE

Request Parameters

Collection GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.
sidebarstringfalseThe sidebar to return widgets for.

Collection POST

ParameterTypeRequiredDefaultDescription
idstringfalseUnique identifier for the widget.
id_basestringfalseThe type of the widget. Corresponds to ID in widget-types endpoint.
sidebarstringtruewp_inactive_widgetsThe sidebar the widget belongs to.
instanceobjectfalseInstance settings of the widget, if supported.
form_datastringfalseURL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

Single GET

ParameterTypeRequiredDefaultDescription
contextstringfalseviewScope under which the request is made; determines fields present in response.

Single POST, PUT, PATCH

ParameterTypeRequiredDefaultDescription
idstringfalseUnique identifier for the widget.
id_basestringfalseThe type of the widget. Corresponds to ID in widget-types endpoint.
sidebarstringfalseThe sidebar the widget belongs to.
instanceobjectfalseInstance settings of the widget, if supported.
form_datastringfalseURL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

Single DELETE

ParameterTypeRequiredDefaultDescription
forcebooleanfalseWhether to force removal of the widget, or move it to the inactive sidebar.

Response Schema (Item)

FieldTypeDescription
idstringUnique identifier for the widget.
id_basestringThe type of the widget. Corresponds to ID in widget-types endpoint.
sidebarstringThe sidebar the widget belongs to.
renderedstringHTML representation of the widget. (read-only)
rendered_formstringHTML representation of the widget admin form. (read-only)
instanceobjectInstance settings of the widget, if supported.
form_datastringURL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

Authentication

  • Read/Write: edit_theme_options.

Example Requests

bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/widgets"
bash
curl -X POST "https://wordpress.org/news/wp-json/wp/v2/widgets" 
  -H 'Authorization: Basic <app-password>' 
  -H 'Content-Type: application/json' 
  -d '{"title":"Example"}'
bash
curl -X GET "https://wordpress.org/news/wp-json/wp/v2/widgets/1"

Example Response (trimmed)

json
{
  "id": 1,
  "_links": {
    "self": [{ "href": "/wp/v2/widgets/1" }]
  }
}