這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

JSON REST API (WP API) Categories and Tags

外掛說明

The JSON REST API (WP API) as of version 1.1.1 does not allow you to specify tags or categories
when createing or editing posts (it appears this will be added in a later release). This plugin addresses that problem by allowing categories and tags to be
passed in the JSON data when creating/editing posts.

An example JSON post that can be made using the JSON REST API (WP API) (described in detail here) to create a post in WordPress would be:

{"title":"Hello World!","content_raw":"Content","excerpt_raw":"Excerpt"}

In order to add tags/categories you would add an array called “x-categories” and/or and array called “x-tags” to the JSON data, for example:

{"title":"Hello World!","content_raw":"Content","excerpt_raw":"Excerpt","x-tags":["tag1","tag2"],"x-categories":["General","15"]}

The example creates a post and assignes the tags “tag1” and “tag2” as well as placing the post in the category named “General” and category ID 15. The tags do not have to exist prior to use. Categories must exist prior to use and may be expressed and either category names or category IDs. The “x-” prefixes were used to avoid any conflicts in functionality with the JSON REST API (WP API) plugin.

Because this plugin relies on the JSON parsing functionallity provided by the JSON REST API (WP API) plugin the alternate syntax using a multi-part-form body should also work.

By default the tags/categories specified when editing a post will replace any tags/categories already assigned to the post. This behavior can be changed so that tags/categories are appened instead, simply open the json-rest-api-wp-api-categories-and-tags folder in the WordPress plugins folder and edit json-rest-api-patch.php. On
line 12 of the file is a variable that should be set to true in order to have tags/categories appended instead of replaced.

安裝方式

  1. Upload the json-rest-api-patch folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

使用者評論

這個外掛目前沒有任何使用者評論。

參與者及開發者

以下人員參與了開源軟體〈JSON REST API (WP API) Categories and Tags〉的開發相關工作。

參與者

變更記錄

1.0

  • Initial release

1.01

  • Fixed category id integer check; thanks to trevordevore