---
description: 页面属性
---

# 页面

## 页面属性 data

| 属性名                 | 说明          | 必填 | 类型          |
| ------------------- | ----------- | -- | ----------- |
| ID                  | 页面id        | 是  | \[int]      |
| post\_date          | 创建时间(local) | 是  | \[datetime] |
| post\_date\_gmt     | 创建时间(GMT)   | 是  | \[datetime] |
| post\_modified      | 更新时间(local) | 是  | \[datetime] |
| post\_modified\_gmt | 更新时间(GMT)   | 是  | \[datetime] |
| title               | 页面标题        | 是  | \[string]   |
| content             | 页面内容        | 是  | \[string]   |
| status              | 页面状态        | 是  | \[string]   |
| slug                | 页面slug      | 是  | \[string]   |
| seo\_title          | 页面SEO标题     | 是  | \[string]   |
| seo\_description    | 页面SEO描述     | 是  | \[string]   |
| public\_url         | 标题链接        | 是  | \[string]   |
| base\_url           | 主链接         | 是  | \[string]   |
| path                | 路径          | 是  | \[string]   |
| update\_date\_gmt   | 更新时间GMT     | 是  | \[datetime] |
| template            | 模板类型        | 是  | \[string]   |

## 列表参数 links

| 属性名   | 说明   | 必填 | 类型        |
| ----- | ---- | -- | --------- |
| first | 第一页  | 是  | \[string] |
| last  | 最后一页 | 是  | \[string] |
| prev  | 上一页  | 是  | \[string] |
| next  | 下一页  | 是  | \[string] |

## 列表参数 meta

| 属性名           | 说明       | 必填 | 类型         |
| ------------- | -------- | -- | ---------- |
| current\_page | 当前页码     | 是  | \[int]     |
| from          | 当前页起始条数号 | 是  | \[number]] |
| last\_page    | 尾页页码     | 是  | \[number]  |
| path          | 分页基本url  | 是  | \[string]  |
| per\_page     | 每页显示条数   | 是  | \[number]  |
| to            | 当前页结束条数号 | 是  | \[number]  |
| total         | 数据总数     | 是  | \[number]  |

## 获取页面列表

<mark style="color:blue;">`GET`</mark>` ``/openapi/2024-10/pages`&#x20;

权限要求：`read_content`

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | String | Authorization |
| Accept        | String | Accept        |

{% tabs %}
{% tab title="200: OK 响应内容" %}
```javascript
{
    "data": [
        {
            "ID": 306,
            "post_date": "2021-11-08 10:35:05",
            "post_date_gmt": "2021-11-08 02:35:05",
            "post_modified": "2021-11-08 10:35:05",
            "post_modified_gmt": "2021-11-08 02:35:05",
            "title": "dwad",
            "content": "<p>dawd</p>",
            "status": "private",
            "slug": "dwad",
            "seo_title": null,
            "seo_description": null,
            "public_url": "http://shop.com/pages/dwad",
            "base_url": "http://shop.com/pages",
            "path": "/pages/dwad",
            "update_date_gmt": "2021-11-08T02:35:05+00:00",
            "template": "page"
        },
    ],
    "links": {
        "first": "http://zyshop.frp.codefriend.top/openapi/2024-10/pages?page=1",
        "last": "http://zyshop.frp.codefriend.top/openapi/2024-10/pages?page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "path": "http://zyshop.frp.codefriend.top/openapi/2024-10/pages",
        "per_page": 25,
        "to": 8,
        "total": 8
    }
}
```
{% endtab %}
{% endtabs %}

## 获取单个页面详情

<mark style="color:blue;">`GET`</mark>` ``/openapi/2024-10/pages/{id}`&#x20;

权限要求：`read_content`

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | String | Authorization |
| Accept        | String | Accept        |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | \[int] | 请求id        |

{% tabs %}
{% tab title="200: OK 响应内容" %}
```javascript
{
    "ID": 302,
    "post_date": "2021-11-08 10:21:47",
    "post_date_gmt": "2021-11-08 02:21:47",
    "post_modified": "2021-11-08 10:21:47",
    "post_modified_gmt": "2021-11-08 02:21:47",
    "title": "222",
    "content": "333",
    "status": "private",
    "slug": "222-3",
    "seo_title": null,
    "seo_description": null,
    "public_url": "http://shop.com/pages/222-3",
    "base_url": "http://shop.com/pages",
    "path": "/pages/222-3",
    "update_date_gmt": "2021-11-08T02:21:47+00:00",
    "template": "page"
}
```
{% endtab %}
{% endtabs %}

## 更新页面信息

<mark style="color:orange;">`PUT`</mark>` ``/openapi/2024-10/pages/{id}`&#x20;

权限要求：`read_content`

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | String | Authorization |
| Accept        | String | Accept        |

#### Request Body

| Name             | Type   | Description   |
| ---------------- | ------ | ------------- |
| id               | int    | 页面id          |
| title            | String | 标题            |
| status           | String | 状态            |
| content          | String | 内容            |
| seo\_title       | String | SEO标题         |
| seo\_description | String | SEO描述         |
| slug             | String | 每个页面的SLUG必须唯一 |
| template         | String | 模板类型          |

{% tabs %}
{% tab title="200: OK 响应内容" %}
```json
{
    "ID": 302,
    "post_date": "2021-11-08 10:21:47",
    "post_date_gmt": "2021-11-08 02:21:47",
    "post_modified": "2021-11-10 12:58:12",
    "post_modified_gmt": "2021-11-10 04:58:12",
    "title": "terms of service",
    "content": "333",
    "status": "publish",
    "slug": "222-3",
    "seo_title": null,
    "seo_description": null,
    "public_url": "http://shop.com/pages/222-3",
    "base_url": "http://shop.com/pages",
    "path": "/pages/222-3",
    "update_date_gmt": "2021-11-10T04:58:12+00:00",
    "template": "page"
}
```
{% endtab %}
{% endtabs %}

## 删除页面

<mark style="color:red;">`DELETE`</mark>` ``/openapi/2024-10/pages/{id}`&#x20;

权限要求：`write_content`

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | String | Authorization |
| Accept        | String | Accept        |

#### Request Body

| Name | Type | Description |
| ---- | ---- | ----------- |
| id   | int  | 页面id        |

{% tabs %}
{% tab title="204: No Content " %}
```javascript
{
    // Response
}
```
{% endtab %}
{% endtabs %}

## 创建页面

<mark style="color:green;">`POST`</mark>` ``/openapi/2024-10/pages`&#x20;

权限要求：`write_content`

#### Headers

| Name          | Type   | Description   |
| ------------- | ------ | ------------- |
| Authorization | String | Authorization |
| Accept        | String | Accept        |

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| title    | String | 标题          |
| content  | String | 内容          |
| status   | String | 状态          |
| template | String | 模板类型        |

{% tabs %}
{% tab title="200: OK 响应内容" %}
```javascript
{
    "post_modified_gmt": "2021-11-10 05:10:44",
    "post_modified": "2021-11-10 13:10:44",
    "post_date_gmt": "2021-11-10 05:10:44",
    "post_date": "2021-11-10 13:10:44",
    "ID": 307,
    "title": "da",
    "content": "<p>no content</p>",
    "status": "publish",
    "slug": "da",
    "seo_title": null,
    "seo_description": null,
    "public_url": "http://shop.com/pages/da",
    "base_url": "http://shop.com/pages",
    "path": "/pages/da",
    "update_date_gmt": "2021-11-10T05:10:44+00:00",
    "template": "contact_page"
}
```
{% endtab %}
{% endtabs %}
