[WordPress] 外掛分享: REST API – Filter Fields

首頁外掛目錄 › REST API – Filter Fields
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
700+
安裝啟用
★★★★★
5/5 分(10 則評價)
2088 天前
最後更新
問題解決
WordPress 4.4+ v1.0.8 上架:2015-10-28

內容簡介

自 WordPress 4.9.? 版本以來,WordPress 已經將此外掛的功能包含在 WordPress 核心之中。

請查看 https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields,以瞭解在 WordPress 核心中包含的功能。他們通過過濾從數據庫中提取的數據量使其更好。

由於已被核心功能取代,因此不再維護此外掛。

wp-rest-api-v2 返回了許多屬性。
只返回應用程序所需的屬性可能非常有用(或使用行動數據友好的方式)。

如果您只想要某些文章的標題和鏈接,返回內容或摘要就沒有意義。

這不僅限於文章,也適用於自定義文章類型、分類、頁面、術語、分類和評論。

它可以返回以下內容(使用 fields=id,title.rendered,link 作為 GET 參數):

{
"id": 2138,
"link": "http://worldofict.nl/tip/2138-rechtenvrije-fotos/",
"title": {
"rendered": "Rechtenvrije foto’s"
}
}

附註

如果您指定字段,以使其不返回數據,則將發送默認回覆給客戶端。
(對於開發人員)如果此外掛遇到了問題?Github
如果您喜歡此外掛,請考慮贊助我

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.8) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「REST API – Filter Fields」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Since wordpress version 4.9.? wordpress includes the functionality provided by this plugin in the core of wordpress.
Checkout https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields for functionality included in the wordpress core,
they made it even better by filtering the amount of data pulled from the database.
This plugin will no longer be maintained since it has been superseded by the core functionality.
The wp-rest-api-v2 returns a lot of properties.
It could be very useful (or mobile-data-friendly) to only return the properties needed by the application.
If you only want titles and links of some articles it doesn’t make sense to return the content or the excerpt.
This isn’t limited to posts, it also works on custom posttypes, categories, pages, terms, taxonomies and comments.
Instead of returning:
{
"id": 2138,
"date": "2015-10-25T15:31:03",
"guid": {
"rendered": "http://worldofict.nl/?p=2138"
},
"modified": "2015-10-25T15:31:03",
"modified_gmt": "2015-10-25T14:31:03",
"slug": "rechtenvrije-fotos",
"type": "post",
"link": "http://worldofict.nl/tip/2138-rechtenvrije-fotos/",
"title": {
"rendered": "Rechtenvrije foto’s"
},
"content": {
"rendered": ".. A lot of content .. "
},
"excerpt": {
"rendered": " .. A lot of content ..."
},
"author": 2,
"featured_image": 2139,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"format": "standard",
//.. even more tags ....
}

It can return (with fields=id,title.rendered,link as GET parameter)
{
"id": 2138,
"link": "http://worldofict.nl/tip/2138-rechtenvrije-fotos/",
"title": {
"rendered": "Rechtenvrije foto’s"
}
}

Notes

If you specify fields so it wouldn’t return data the default response is send back to the client.
(for developers) something wrong with this plugin? Github
If you liked the plugin consider sponsoring me

延伸相關外掛

文章
Filter
Mastodon