REST API 文档

💡 云策文档标注

概述

本文档介绍了 WordPress 中 Rendered Block 的架构和创建方法,包括其字段定义和 API 端点,适用于开发者处理块渲染操作。

关键要点

  • Rendered Block 记录包含 `rendered` 字段,表示渲染后的块内容,数据类型为字符串,仅在 `edit` 上下文中出现。
  • 创建 Rendered Block 使用 POST 请求到 `/wp/v2/block-renderer/` 端点,需提供 `name`、`context`、`attributes` 和 `post_id` 等参数。
  • 除非使用 `_filter` 查询参数或字段仅出现在特定上下文,否则响应会包含架构定义的所有字段。

代码示例

POST /wp/v2/block-renderer/<name>

📄 原文内容

Schema

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

rendered The rendered block.

JSON data type: string

Context: edit

Create a Rendered Block

Arguments

<a href="#schema-name">name</a> Unique registered name for the block.
<a href="#schema-context">context</a> Scope under which the request is made; determines fields present in response.

Default: view

One of: edit

<a href="#schema-attributes">attributes</a> Attributes for the block.
<a href="#schema-post_id">post_id</a> ID of the post context.

Definition

POST /wp/v2/block-renderer/<name>