REST API 文档

💡 云策文档标注

概述

本文档介绍了 WordPress REST API 中站点设置(Site Settings)的架构、字段定义以及相关操作端点。站点设置包含网站标题、描述、URL、时区、语言、显示选项等核心配置信息,可通过 GET 和 POST 请求进行查询和更新。

关键要点

  • 站点设置定义了网站的基本配置字段,如标题、描述、URL、时区、语言、默认分类等。
  • 所有字段均遵循 JSON 数据格式,部分字段有特定格式要求(如 URI、email)或可选值(如 open、closed)。
  • 可通过 GET /wp/v2/settings 端点查询站点设置,无需参数。
  • 可通过 POST /wp/v2/settings 端点更新站点设置,支持更新所有定义的字段。
  • 响应字段受 `_filter` 查询参数或特定上下文影响,默认包含所有架构字段。

代码示例

GET /wp/v2/settings
$ curl https://example.com/wp-json/wp/v2/settings

POST /wp/v2/settings

📄 原文内容

Schema

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

title Site title.

JSON data type: string

Context:

description Site tagline.

JSON data type: string

Context:

url Site URL.

JSON data type: string,
Format: uri

Context:

email This address is used for admin purposes, like new user notification.

JSON data type: string,
Format: email

Context:

timezone A city in the same timezone as you.

JSON data type: string

Context:

date_format A date format for all date strings.

JSON data type: string

Context:

time_format A time format for all time strings.

JSON data type: string

Context:

start_of_week A day number of the week that the week should start on.

JSON data type: integer

Context:

language WordPress locale code.

JSON data type: string

Context:

use_smilies Convert emoticons like 🙂 and 😛 to graphics on display.

JSON data type: boolean

Context:

default_category Default post category.

JSON data type: integer

Context:

default_post_format Default post format.

JSON data type: string

Context:

posts_per_page Blog pages show at most.

JSON data type: integer

Context:

show_on_front What to show on the front page

JSON data type: string

Context:

page_on_front The ID of the page that should be displayed on the front page

JSON data type: integer

Context:

page_for_posts The ID of the page that should display the latest posts

JSON data type: integer

Context:

default_ping_status Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.

JSON data type: string

Context:

One of: open, closed

default_comment_status Allow people to submit comments on new posts.

JSON data type: string

Context:

One of: open, closed

site_icon Site icon.

JSON data type: integer

Context:

Retrieve a Site Setting

Definition & Example Request

GET /wp/v2/settings

Query this endpoint to retrieve a specific Site Setting record.

$ curl https://example.com/wp-json/wp/v2/settings

There are no arguments for this endpoint.

Update a Site Setting

Arguments

<a href="#schema-title">title</a> Site title.
<a href="#schema-description">description</a> Site tagline.
<a href="#schema-url">url</a> Site URL.
<a href="#schema-email">email</a> This address is used for admin purposes, like new user notification.
<a href="#schema-timezone">timezone</a> A city in the same timezone as you.
<a href="#schema-date_format">date_format</a> A date format for all date strings.
<a href="#schema-time_format">time_format</a> A time format for all time strings.
<a href="#schema-start_of_week">start_of_week</a> A day number of the week that the week should start on.
<a href="#schema-language">language</a> WordPress locale code.
<a href="#schema-use_smilies">use_smilies</a> Convert emoticons like 🙂 and 😛 to graphics on display.
<a href="#schema-default_category">default_category</a> Default post category.
<a href="#schema-default_post_format">default_post_format</a> Default post format.
<a href="#schema-posts_per_page">posts_per_page</a> Blog pages show at most.
<a href="#schema-show_on_front">show_on_front</a> What to show on the front page
<a href="#schema-page_on_front">page_on_front</a> The ID of the page that should be displayed on the front page
<a href="#schema-page_for_posts">page_for_posts</a> The ID of the page that should display the latest posts
<a href="#schema-default_ping_status">default_ping_status</a> Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.
One of: open, closed
<a href="#schema-default_comment_status">default_comment_status</a> Allow people to submit comments on new posts.
One of: open, closed
<a href="#schema-site_logo">site_logo</a> Site logo.
<a href="#schema-site_icon">site_icon</a> Site icon.

Definition

POST /wp/v2/settings

Example Request