Skip to content

Latest commit

 

History

History
309 lines (285 loc) · 7.74 KB

widgets.md

File metadata and controls

309 lines (285 loc) · 7.74 KB


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.

id

Unique identifier for the widget.

JSON data type: string

Context: view, edit, embed

id_base

The type of the widget. Corresponds to ID in widget-types endpoint.

JSON data type: string

Context: view, edit, embed

sidebar

The sidebar the widget belongs to.

JSON data type: string

Context: view, edit, embed

rendered

HTML representation of the widget.

JSON data type: string

Read only

Context: view, edit, embed

rendered_form

HTML representation of the widget admin form.

JSON data type: string

Read only

Context: edit

instance

Instance settings of the widget, if supported.

JSON data type: object

Context: edit

form_data

URL-encoded form data from the widget admin form. Used to update a widget that does not support instance. Write only.

JSON data type: string

Context:

</div>

Retrieve a Widget

	<h3>Definition & Example Request</h3>

	<code>GET /wp/v2/widgets</code>

	<p>Query this endpoint to retrieve a specific widget record.</p>

	<code>$ curl https://example.com/wp-json/wp/v2/widgets</code>
</div>
<div class="secondary">
		<h3>Arguments</h3>
<table class="arguments">
				<tr>
			<td>
										<code>context</code><br />
								</td>
			<td>
										<p>Scope under which the request is made; determines fields present in response.</p>
																				<p class="default">
						Default: <code>view</code>
					</p>
															<p>One of: <code>view</code>, <code>embed</code>, <code>edit</code></p>
								</td>
		</tr>
				<tr>
			<td>
										<code>sidebar</code><br />
								</td>
			<td>
										<p>The sidebar to return widgets for.</p>
																							</td>
		</tr>
		</table>

</div>

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.

</div>
<div class="secondary">
	<h3>Definition</h3>

	<code>POST /wp/v2/widgets</code>
</div>

Retrieve a Widget

	<h3>Definition & Example Request</h3>

	<code>GET /wp/v2/widgets/&lt;id&gt;</code>

	<p>Query this endpoint to retrieve a specific widget record.</p>

	<code>$ curl https://example.com/wp-json/wp/v2/widgets/&lt;id&gt;</code>
</div>
<div class="secondary">
		<h3>Arguments</h3>
<table class="arguments">
				<tr>
			<td>
										<code>context</code><br />
								</td>
			<td>
										<p>Scope under which the request is made; determines fields present in response.</p>
																				<p class="default">
						Default: <code>view</code>
					</p>
															<p>One of: <code>view</code>, <code>embed</code>, <code>edit</code></p>
								</td>
		</tr>
		</table>

</div>

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.

</div>
<div class="secondary">
	<h3>Definition</h3>

	<code>POST /wp/v2/widgets/&lt;id&gt;</code>

	<h3>Example Request</h3>

	<code></code>
</div>

Delete a Widget

Arguments

force

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

</div>
<div class="secondary">
	<h3>Definition</h3>

	<code>DELETE /wp/v2/widgets/&lt;id&gt;</code>

	<h3>Example Request</h3>

	<code>$ curl -X DELETE https://example.com/wp-json/wp/v2/widgets/&lt;id&gt;</code>
</div>