[WordPress] 外掛分享: WP REST API – Pure Taxonomies

首頁外掛目錄 › WP REST API – Pure Taxonomies
500+
安裝啟用
★★★★★
5/5 分(5 則評價)
3675 天前
最後更新
問題解決
WordPress 4.4+ v1.0 上架:2016-02-11

內容簡介

現在您不需要額外的請求來獲取分類信息(term_id、name、slug、term_group、term_taxonomy_id、taxonomy、description、parent、count、filter),其ID已經在默認的JSON響應中可用。

現在所有可用的分類法的信息都在您的JSON響應的‘pure_taxonomies’字段中。它適用於所有自定義添加的分類法和自定義文章類型。

例如,在‘wp-json/wp/v2/posts’中,您可以找到默認的‘categories’和‘tags’字段以及包含其ID的自定義添加分類法的名稱。使用此外掛,您也可以找到新的‘pure_taxonomies’字段,其中包含所有可用的‘categories’、‘tags’和自定義分類法數據。

之前:
{

categories: [
3
],
tags: [
2
],
custom_taxonomy_name: [
1
]

}

之後:
{

pure_taxonomies: {
categories: [
{
term_id: 3,
name: “First category”,
slug: “first-category”,
term_group: 0,
term_taxonomy_id: 3,
taxonomy: “category”,
description: “”,
parent: 0,
count: 3,
filter: “raw”,
cat_ID: 3,
category_count: 3,
category_description: “”,
cat_name: “First category”,
category_nicename: “first-category”,
category_parent: 0
}
],
tags: [
{
term_id: 2,
name: “First tag”,
slug: “first-tag”,
term_group: 0,
term_taxonomy_id: 2,
taxonomy: “post_tag”,
description: “”,
parent: 0,
count: 2,
filter: “raw”
}
],
custom_taxonomy_name: [
{
term_id: 1,
name: “Custom Taxonomy Name”,
slug: “custom-taxonomy-name”,
term_group: 0,
term_taxonomy_id: 1,
taxonomy: “custom_taxonomy_name”,
description: “”,
parent: 0,
count: 1,
filter: “raw”
}
]
}

}

透過這個連結可以查看我製作的有用的 rest-api 外掛:https://wordpress.org/plugins/tags/andrew-magik-rest-api.

外掛標籤

開發者團隊

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

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

原文外掛簡介

Now you have no need to make additional requests to get taxonomy info (term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent, count, filter) from their id that is available in the default json response.
Now all available taxonomy data is available in ‘pure_taxonomies’ field from your json response. It works for all custom added taxonomies, and for custom post types.
For example in ‘wp-json/wp/v2/posts’ you can find default fields ‘categories’, ‘tags’ and name of custom added taxonomies that contain only its id. With this plugin you can also find new ‘pure_taxonomies’ field that include all available ‘categories’, ‘tags’ and custom taxonomies data.
Before:
{

categories: [
3
],
tags: [
2
],
custom_taxonomy_name: [
1
]

}
After:
{

pure_taxonomies: {
categories: [
{
term_id: 3,
name: “First category”,
slug: “first-category”,
term_group: 0,
term_taxonomy_id: 3,
taxonomy: “category”,
description: “”,
parent: 0,
count: 3,
filter: “raw”,
cat_ID: 3,
category_count: 3,
category_description: “”,
cat_name: “First category”,
category_nicename: “first-category”,
category_parent: 0
}
],
tags: [
{
term_id: 2,
name: “First tag”,
slug: “first-tag”,
term_group: 0,
term_taxonomy_id: 2,
taxonomy: “post_tag”,
description: “”,
parent: 0,
count: 2,
filter: “raw”
}
],
custom_taxonomy_name: [
{
term_id: 1,
name: “Custom Taxonomy Name”,
slug: “custom-taxonomy-name”,
term_group: 0,
term_taxonomy_id: 1,
taxonomy: “custom_taxonomy_name”,
description: “”,
parent: 0,
count: 1,
filter: “raw”
}
]
}

}
Check my other useful rest-api plugins: https://wordpress.org/plugins/tags/andrew-magik-rest-api.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon