跳转到主要内容

Tags

Schema

The schema defines all the fields that exist within a tag 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 term.

JSON data type: integer

Read only

Context: view, embed, edit

count

Number of published posts for the term.

JSON data type: integer

Read only

Context: view, edit

description

HTML description of the term.

JSON data type: string

Context: view, edit

name

HTML title for the term.

JSON data type: string

Context: view, embed, edit

slug

An alphanumeric identifier for the term unique to its type.

JSON data type: string

Context: view, embed, edit

taxonomy

Type attribution for the term.

JSON data type: string

Read only

Context: view, embed, edit

One of: post_tag

meta

Meta fields.

JSON data type: object

Context: view, edit

</div>

List Tags

Query this endpoint to retrieve a collection of tags. The response you receive can be controlled and filtered using the URL query parameters below.

	<h3>Definition</h3>

	<code>GET /wp/v2/tags</code>

	<h3>Example Request</h3>

	<code>$ curl https://example.com/wp-json/wp/v2/tags</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>page</code><br />
								</td>
			<td>
										<p>Current page of the collection.</p>
																				<p class="default">
						Default: <code>1</code>
					</p>
													</td>
		</tr>
				<tr>
			<td>
										<code>per_page</code><br />
								</td>
			<td>
										<p>Maximum number of items to be returned in result set.</p>
																				<p class="default">
						Default: <code>10</code>
					</p>
													</td>
		</tr>
				<tr>
			<td>
										<code>search</code><br />
								</td>
			<td>
										<p>Limit results to those matching a string.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>exclude</code><br />
								</td>
			<td>
										<p>Ensure result set excludes specific IDs.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>include</code><br />
								</td>
			<td>
										<p>Limit result set to specific IDs.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>offset</code><br />
								</td>
			<td>
										<p>Offset the result set by a specific number of items.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>order</code><br />
								</td>
			<td>
										<p>Order sort attribute ascending or descending.</p>
																				<p class="default">
						Default: <code>asc</code>
					</p>
															<p>One of: <code>asc</code>, <code>desc</code></p>
								</td>
		</tr>
				<tr>
			<td>
										<code>orderby</code><br />
								</td>
			<td>
										<p>Sort collection by term attribute.</p>
																				<p class="default">
						Default: <code>name</code>
					</p>
															<p>One of: <code>id</code>, <code>include</code>, <code>name</code>, <code>slug</code>, <code>include_slugs</code>, <code>term_group</code>, <code>description</code>, <code>count</code></p>
								</td>
		</tr>
				<tr>
			<td>
										<code>hide_empty</code><br />
								</td>
			<td>
										<p>Whether to hide terms not assigned to any posts.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>post</code><br />
								</td>
			<td>
										<p>Limit result set to terms assigned to a specific post.</p>
																							</td>
		</tr>
				<tr>
			<td>
										<code>slug</code><br />
								</td>
			<td>
										<p>Limit result set to terms with one or more specific slugs.</p>
																							</td>
		</tr>
		</table>

</div>

Create a Tag

Arguments

description

HTML description of the term.

name

HTML title for the term.

Required: 1

slug

An alphanumeric identifier for the term unique to its type.

meta

Meta fields.

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

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

Retrieve a Tag

	<h3>Definition & Example Request</h3>

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

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

	<code>$ curl https://example.com/wp-json/wp/v2/tags/&lt;id&gt;</code>
</div>
<div class="secondary">
		<h3>Arguments</h3>
<table class="arguments">
				<tr>
			<td>
										<code>id</code><br />
								</td>
			<td>
										<p>Unique identifier for the term.</p>
																							</td>
		</tr>
				<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 Tag

Arguments

id

Unique identifier for the term.

description

HTML description of the term.

name

HTML title for the term.

slug

An alphanumeric identifier for the term unique to its type.

meta

Meta fields.

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

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

	<h3>Example Request</h3>

	<code></code>
</div>

Delete a Tag

Arguments

id

Unique identifier for the term.

force

Required to be true, as terms do not support trashing.

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

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

	<h3>Example Request</h3>

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