wordpress开发手册
2.3 PHP
3.2 WordPress 插件结构和⽣命周期

6.1.5 提问:如何使⽤WordPress REST API创建和更新⽂章?

使⽤WordPress REST API创建和更新⽂章WordPress REST API允许通过HTTP请求创建和更新⽂章。以下是如何使⽤WordPress REST API创建和更新⽂章的步骤:创建⽂章

1. Endpoint 发送POST请求到 https://yourwebsite.com/wp-json/wp/v2/posts

2. Headers 设置 Content-Type: application/json

3. Body 提供⽂章详情,如标题、内容等,⽰例:{} "title": "新⽂章标题","content": "新⽂章内容","status": "publish"

4. 权限 需要管理员权限或具有发布⽂章权限

5. 响应 成功创建会返回新⽂章的ID更新⽂章

1. Endpoint 发送POST请求到 https://yourwebsite.com/wp-json/wp/v2/posts/{post_id}

2. Headers 设置 Content-Type: application/json

3. Body 提供要更新的⽂章详情,⽰例:{} "title": "更新后的⽂章标题","content": "更新后的⽂章内容"

4. 权限 需要管理员权限或具有编辑⽂章权限

5. 响应 成功更新会返回更新后的⽂章详情通过WordPress REST API,可以⽅便地在WordPress⽹站上创建和更新⽂章。

10 Screens$8,029

I will design rough sketches for upto 5 Screens of your website/Mobile app.

3 Days Delivery 1 Revision
  • Source File
  • Commercial Use
  • Interactive Mockup
  • 10 Pages

20 Screens$16,029

I will design rough sketches for upto 5 Screens of your website/Mobile app.

3 Days Delivery
  • Source File
  • Commercial Use
  • Interactive Mockup
  • 10 Pages

30 Screens$24,029

I will design rough sketches for upto 5 Screens of your website/Mobile app.

3 Days Delivery
  • Source File
  • Commercial Use
  • Interactive Mockup
  • 10 Pages
0.889291s