前言介紹
- 這款 WordPress 外掛「JSON REST API (WP API) Categories and Tags」是 2014-09-16 上架。
- 目前有 40 個安裝啟用數。
- 上一次更新是 2014-09-20,距離現在已有 3880 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.9 以上版本才可以安裝。
- 有 2 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
wizadsl |
外掛標籤
api | JSON | rest | patch | rest-api |
內容簡介
截至版本 1.1.1,JSON REST API(WP API) 不允許用戶指定標籤或類別,在創建或編輯文章時(似乎後續版本會加入此功能)。此外掛解決了此問題,允許在創建/編輯文章時在 JSON 資料中傳遞類別和標籤。
可使用JSON REST API(WP API)製作的一個範例 JSON 文章(詳細說明此處),創建 WordPress 文章的內容如下:
{"title":"Hello World!","content_raw":"Content","excerpt_raw":"Excerpt"}
要添加類別或標籤,您需要在 JSON 資料中添加一個名為“x-categories”的陣列或一個名為“x-tags”的陣列,例如:
{"title":"Hello World!","content_raw":"Content","excerpt_raw":"Excerpt","x-tags":["tag1","tag2"],"x-categories":["General","15"]}
此範例創建了一篇文章,並分配了標籤“tag1”和“tag2”,將文章置於名為“General”的類別和類別ID 15中。標籤不必在使用前存在。類別必須在使用前存在,並且可以表達為類別名稱或類別 ID。在這個外掛中使用“x-”前綴用於避免與JSON REST API(WP API)外掛功能之間的任何衝突。
因為外掛依賴JSON REST API(WP API)提供的 JSON 解析功能,因此使用多部分表單主體的替代語法也應該有效。
默認情況下,編輯文章時指定的類別或標籤將取代已分配給文章的任何類別或標籤。您可以更改此行為,使類別或標籤附加而不是替換,只需打開 WordPress 插件文件夾中的“json-rest-api-wp-api-categories-and-tags”文件夾,編輯“json-rest-api-patch.php”即可。在第12行上可以找到一個變數,應將其設置為true,才能附加而不是替換標籤或類別。
原文外掛簡介
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.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「JSON REST API (WP API) Categories and Tags」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
Test Reports 》- 這個外掛能夠簡化向 WordPress 提交報告的過程,通過提供模板讓你粘貼、填寫每個部分並提交。, - 模板中已包含環境信息,因此你不需要填寫瀏覽器、主題、外...。
WP OPcache Patch 》使用 WordPress 和 OPcache 出現問題了嗎?升級核心、外掛或佈景主題後可能會發生此情況。, 此外掛會在升級後重設全部快取,這樣您就不必反覆看到「請更新!...。