REST API 文档

💡 云策文档标注

概述

本文档介绍了 WordPress 中 Global_Styles 的 REST API 端点,包括其数据结构和操作方式。它定义了全局样式配置的字段,并提供了检索和更新这些配置的端点。

关键要点

  • Global_Styles 记录包含 id、styles、settings 和 title 字段,每个字段有特定的 JSON 数据类型和上下文。
  • 可以使用 GET /wp/v2/global-styles/<id> 端点来检索特定的全局样式配置。
  • 可以使用 POST /wp/v2/global-styles/<id> 端点来更新全局样式配置,参数包括 styles、settings 和 title。

代码示例

GET /wp/v2/global-styles/<id>
$ curl https://example.com/wp-json/wp/v2/global-styles/<id>

📄 原文内容

Schema

The schema defines all the fields that exist within a global_styles 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 ID of global styles config.

JSON data type: string

Read only

Context: embed, view, edit

styles Global styles.

JSON data type: object

Context: view, edit

settings Global settings.

JSON data type: object

Context: view, edit

title Title of the global styles variation.

JSON data type: object or string

Context: embed, view, edit

Retrieve a Global_Styles

Definition & Example Request

GET /wp/v2/global-styles/<id>

Query this endpoint to retrieve a specific global_styles record.

$ curl https://example.com/wp-json/wp/v2/global-styles/<id>

Arguments

id The id of a template

Update a Global_Styles

Arguments

<a href="#schema-styles">styles</a> Global styles.
<a href="#schema-settings">settings</a> Global settings.
<a href="#schema-title">title</a> Title of the global styles variation.

Definition

POST /wp/v2/global-styles/<id>

Example Request