Widget Types
These routes provide information about registered widget types, render their forms, and encode instance settings.
Available routes (endpoints are described below):
/wp/v2/widget-types
/wp/v2/widget-types/{id}
/wp/v2/widget-types/{id}/encode
/wp/v2/widget-types/{id}/render
Controller classes:
Contents:
Resource schema
The schema lists fields returned by the resource. Fields depend on the context and user capabilities.
| Field | Context | Description |
|---|---|---|
| id | view, edit |
Resource field. |
| name | view, edit |
Resource field. |
| description | view, edit |
Resource field. |
| is_multi | view, edit |
Resource field. |
| classname | view, edit |
Resource field. |
| widget_class | view, edit |
Resource field. |
/wp/v2/widget-types
An OPTIONS request returns methods, parameters, and the complete schema for the selected route.
$ curl -X OPTIONS -i https://example.com/wp-json/wp/v2/widget-types
Get data
Request type
GET /wp/v2/widget-types
Request parameters
- $context(string)
- Response context:
view,embed, oredit. - $page(integer)
- Collection page number.
- $per_page(integer)
- Number of items per page.
Request example
$ curl https://example.com/wp-json/wp/v2/widget-types
/wp/v2/widget-types/{id}
Get a widget type
Returns information about one registered widget type.
Request type
GET /wp/v2/widget-types/{id}
Request parameters
- $id(string) (required)
- Widget type identifier.
- $context(string)
- Response context:
view,embed, oredit.
Request example
$ curl https://example.com/wp-json/wp/v2/widget-types/{id}
/wp/v2/widget-types/{id}/encode
Encode widget settings
Converts serialized widget-form data into settings for a widget instance.
Request type
POST /wp/v2/widget-types/{id}/encode
Request parameters
- $id(string) (required)
- Widget type identifier.
- $instance(object)
- Current widget-instance settings.
- $form_data(string)
- Serialized widget-form data.
Request example
$ curl -X POST https://example.com/wp-json/wp/v2/widget-types/{id}/encode -d 'form_data=...'
/wp/v2/widget-types/{id}/render
Render a widget form
Returns the HTML markup of the settings form for an instance of the specified widget type.
Request type
POST /wp/v2/widget-types/{id}/render
Request parameters
- $id(string) (required)
- Widget type identifier.
- $instance(object)
- Current widget-instance settings.
Request example
$ curl -X POST https://example.com/wp-json/wp/v2/widget-types/{id}/render