架构
该架构定义了模板部分记录中存在的所有字段。除非使用了 `_filter` 查询参数,或者该架构字段仅出现在特定上下文中,否则预期这些端点的任何响应都将包含以下字段。
id | 模板的 ID。 JSON 数据类型:字符串 只读 上下文: |
slug | 唯一标识模板的 slug。 JSON 数据类型:字符串 上下文: |
theme | 模板的主题标识符。 JSON 数据类型:字符串 上下文: |
type | 模板的类型。 JSON 数据类型:字符串 上下文: |
source | 模板的来源 JSON 数据类型:字符串 只读 上下文: |
origin | 自定义模板的来源 JSON 数据类型:字符串 只读 上下文: |
content | 模板的内容。 JSON 数据类型:对象或字符串 上下文: |
title | 模板的标题。 JSON 数据类型:对象或字符串 上下文: |
description | 模板的描述。 JSON 数据类型:字符串 上下文: |
status | 模板的状态。 JSON 数据类型:字符串 上下文: 其中之一: |
wp_id | 文章 ID。 JSON 数据类型:整数 只读 上下文: |
has_theme_file | 主题文件是否存在。 JSON 数据类型:布尔值 只读 上下文: |
author | 模板作者的 ID。 JSON 数据类型:整数 上下文: |
modified | 模板上次修改的日期,使用站点时区。 JSON 数据类型:字符串 只读 上下文: |
area | 模板部分 intended for use 的位置(页眉、页脚等) JSON 数据类型:字符串 上下文: |
检索模板部分
定义与示例请求
GET /wp/v2/template-parts
查询此端点以检索特定的模板部分记录。
$ curl https://example.com/wp-json/wp/v2/template-parts
参数
context | 请求的作用域;决定响应中存在的字段。 默认值: 其中之一: |
wp_id | 限制为指定的文章 ID。 |
area | 限制为指定的模板部分区域。 |
post_type | 获取模板的文章类型。 |
创建模板部分
参数
slug | 唯一标识模板的 slug。 必填:是 |
theme | 模板的主题标识符。 |
type | 模板的类型。 |
content | 模板的内容。 |
title | 模板的标题。 |
description | 模板的描述。 |
status | 模板的状态。 默认值: 其中之一: |
author | 模板作者的 ID。 |
area | 模板部分 intended for use 的位置(页眉、页脚等) |
定义
POST /wp/v2/template-parts
检索模板部分
定义与示例请求
GET /wp/v2/template-parts/<id>?)[\/\w%-]+)
查询此端点以检索特定的模板部分记录。
$ curl https://example.com/wp-json/wp/v2/template-parts/<id>?)[\/\w%-]+)
参数
id | 模板的 ID |
context | 请求的作用域;决定响应中存在的字段。 默认值: 其中之一: |
更新模板部分
参数
id | 模板的 ID |
slug | 唯一标识模板的 slug。 |
theme | 模板的主题标识符。 |
type | 模板的类型。 |
content | 模板的内容。 |
title | 模板的标题。 |
description | 模板的描述。 |
status | 模板的状态。 其中之一: publish、future、draft、pending、private |
author | 模板作者的 ID。 |
area | 模板部分 intended for use 的位置(页眉、页脚等) |
定义
POST /wp/v2/template-parts/<id>?)[\/\w%-]+)
示例请求
无
删除模板部分
参数
id | 模板的 ID |
force | 是否绕过回收站并强制删除。 |
定义
DELETE /wp/v2/template-parts/<id>?)[\/\w%-]+)
示例请求
$ curl -X DELETE https://example.com/wp-json/wp/v2/template-parts/<id>?)[\/\w%-]+)