前言介紹
- 這款 WordPress 外掛「WUXT Headless WordPress API Extensions」是 2019-05-19 上架。
- 目前有 50 個安裝啟用數。
- 上一次更新是 2019-05-20,距離現在已有 2176 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.7.0 以上版本才可以安裝。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
headless | rest-api | endpoint extension |
內容簡介
此外掛會為 WordPress Rest API 添加一些擴充功能,旨在使 WordPress 作為 Headless CMS 更易於使用。
它原本是為 WUXT 設計的,WUXT 是一個帶有 NuxtJs 的 Docker 開發環境,用於 Headless WordPress。不過,任何其他需要強大的 Headless WordPress 後端的應用程序都可以使用它。
WordPress API 擴充功能
Frontpage 端點:沒有明顯的方法可以通過 Rest API 獲取 WordPress 首頁。要讀取設置,必須授權,這使事情變得不必要地複雜。新端點返回前頁物件(如果已設定),否則返回最新的十篇文章
菜單端點:目前,我不知道有什麼方法可以從 API 獲取菜單。此端點返回整個菜單作為嵌套數組。默認位置是“main”,但您可以請求其他位置。
Slug 端點:如果您正在 WordPress 上構建前端應用程序,則必須考慮如何結構化您的 URL。 WordPress 有兩個默認的文章類型(文章和頁面),並且在 URL 中沒有區分您正在請求哪種類型,因此 http://wp-site.expl/something 可能會導致頁面或文章,具體取決於帶有 something 標題的對象的類型。如果您想在應用程序中反映這種行為,則必須對每個 URL 做兩個請求,一個用於搜索頁面,一個用於搜索文章。使用 Slug 終點來使其一個請求。
分類篩選並且擴充功能:在使用 Rest API 請求篩選分類時,所有查詢都是 OR 查詢。這意味著您可以獲取在分類 A 或 B 中的文章。我們的調整使您可以將所有分類查詢切換為 AND 關係,這樣您就可以選擇同時在分類 A 和 B 中的文章。
Geo 查詢:如果您的應用程序需要通過地理位置靠近獲取文章,則可以使用 Geo 查詢。
WordPress SEO 元欄位:如果啟用了 Yoast WordPress SEO 插件,它們會自動包含在meta對象中。
高級自訂欄位插件在啟用插件後會自動包含在meta對象中。
端點和參數
Frontpage
GET /wp-json/wuxt/v1/front-page
GET /wp-json/wuxt/v1/front-page?_embed
菜單
GET /wp-json/wuxt/v1/menu
GET /wp-json/wuxt/v1/menu?location=
Slug
GET /wp-json/wuxt/v1/slug/
GET /wp-json/wuxt/v1/slug/
分類篩選並且擴充功能
GET /wp-json/wp/v2/posts/?categories=1,2&and=true
GEO 查詢
GET /wp-json/wp/v2/posts/?coordinates=
GET /wp-json/wp/v2/posts/?coordinates=
GET /wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10
GET /wp-json/wp/v2/posts/?coordinates=lat_mkey:52.585,lng_mkey:13.373&distance=10
GET /wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10m
鏈接
原文外掛簡介
This plugin adds a couple of extensions to the WordPress Rest API, which are aimed to make the use of WordPress as headless CMS easier.
It is originally coded for WUXT, a dockerized development environment for headless WordPress combined with NuxtJs. However, it can be used by every other application, which needs a powerful headless WordPress back-end.
WordPress API Extensions
Frontpage endpoint: There is no obvious way to get the WordPress front-page via the Rest API. To read the settings, you have to be authorized, which makes things unnecessary complicated. The new endpoint returns the front-page object if it is set, the ten newest posts otherwise.
Menu endpoint: Right now, there is no way I know of, for getting menus from the API. This endpoint returns an entire menu as nested array. Default location is “main”, but you can request other locations.
Slug endpoint: If you are building a front-end app on top of WordPress, you have to think about how to structure your urls. WordPress has two default post-types (posts & pages) and in the urls is not distinguished which type you are requesting, so http://wp-site.expl/something might lead to a page or a post, dependent on the type of the object with the slug something. If you want to mirror that behaviour in your app, you have to do two requests for each url, one searching pages, one searching posts. To make that one request, use the slug end-point.
Taxonomy filter AND extension: When filtering taxonomies with an Rest API request, all queries are OR-queries. That means you can get posts which are either in category A or B. Our adjustment lets you switch all tax_queries to an AND-relation, so that you can select posts which are both in category A and B.
Geo query: If your application has to get posts by geographical proximity, you can use a geo query.
WordPress SEO meta fields: They are included automatically in the meta object if the Yoast WordPress SEO plugin is activated.
Advanced custom fields are included automatically in the meta object if the plugin is activated.
Endpoints and parameters
Frontpage
GET /wp-json/wuxt/v1/front-page
GET /wp-json/wuxt/v1/front-page?_embed
Menu
GET /wp-json/wuxt/v1/menu
GET /wp-json/wuxt/v1/menu?location=
Slug
GET /wp-json/wuxt/v1/slug/
Taxonomy filter AND extension
GET /wp-json/wp/v2/posts/?categories=1,2&and=true
GEO query
GET /wp-json/wp/v2/posts/?coordinates=
GET /wp-json/wp/v2/posts/?coordinates=
GET /wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10
GET /wp-json/wp/v2/posts/?coordinates=lat_mkey:52.585,lng_mkey:13.373&distance=10
GET /wp-json/wp/v2/posts/?coordinates=52.585,13.373&distance=10m
Links
More detailed end-point description
WUXT
WUXT release blog post
NuxtJs
Credits
Michael Cox Menu Class for returning a menu as array
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WUXT Headless WordPress API Extensions」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
WPGraphQL 》WPGraphQL 是一個免費、開源的 WordPress 外掛,為任何 WordPress 網站提供可延伸的 GraphQL schema 和 API。, 以下是一些有助於你開始使用 WPGraphQL 的連結...。
WPGraphQL for ACF 》- WPGraphQL for Advanced Custom Fields 是一個免費的開源 WordPress 外掛,將 ACF Fields 和 Field Groups 添加到 WPGraphQL Schema 中。, - 創建 ACF Fiel...。
Headless Mode 》Headless 模式為所有嘗試訪問網站的用戶設置重定向。僅允許訪問 REST API、WP GraphQL API 或任何已登錄的用戶嘗試訪問無頭安裝以編輯或創建文章的請求。。
Faust.js 》 Faust 外掛與 Faust NPM 套件 協同工作,透過 GraphQL 調變和 REST API 端點,讓解耦式前端與 WordPress 進行驗證,並扮演 Faust 前端應用程式與 WordPress ...。
Headless WooCommerce Made Easy with CoCart 》重要訊息, 自 2022 年 10 月 5 日起,WordPress.org 中的 CoCart 外掛將不再進行重大更新,此舉是為了專注於付費的 CoCart Pro 版本。只有針對錯誤的次要修復...。
CoCart CORS Support 》這款免費的外掛程式為 CoCart 提供支援 CORS,允許 CoCart 在多個網域上運作。, 只需安裝並啟用,無需任何配置!, 工具和庫, , CoCart Beta Tester 讓您輕鬆...。
WPGraphQL Blocks 》總結:透過wp-graphql外掛,可將Gutenberg塊轉換成JSON資料。, , 問題與答案:, , 問題:wp-graphql是什麼外掛?, 答案:wp-graphql是在WordPress上使用Graph...。
WP Headless 》登入的使用者會被重新導向到文章的編輯頁面,而未登入的使用者必須先登入。這表示您可以根據您的永久連結設定分享一個可讀取的連結直接到編輯器。, 對於任務...。
CoCart – Cart API Enhanced 》此免費 WordPress 外掛是針對 CoCart 的附加元件,可增強傳回給購物車和添加到其中的商品的資料。, 功能, 每個添加到購物車的商品都會傳回以下資料:, , 返回...。
WPGraphQL IDE 》總結:WordPress 外掛 GraphQL IDE for WPGraphQL 為使用者提供一個更直觀的界面,方便進行 GraphQL 查詢和測試。, , 問題與答案:,
- ,
CoCart JWT Authentication 》- CoCart的免費附加元件可讓您透過簡單的JWT Token進行身份驗證。- 啟用PHP HTTP授權標頭- 大多數共享主機默認已禁用HTTP授權標頭。- 要啟用此選項,您需要通...。
Publish to Netlify 》使用 WordPress 作為後端,輕鬆將靜態網站部署到 Netlify。此外掛使用 Netlify webhook 觸發部署流程,建構您的靜態網站。。
WP Headless CMS Framework 》該外掛提供一個框架,將 WordPress 設置為無頭 CMS。, 框架選項包括:, , JSON Web Token 身份驗證(可選), 將 Gutenberg 區塊數據添加到 REST 響應中(可選...。
Gato GraphQL 》- Gato GraphQL 是一個能夠與 WordPress 網站的資料互動的工具,可以檢索、操作和再次儲存任何您所需的資料, - Gato GraphQL 可以處理來自多個外掛的功能:, ...。
Redirect Front-end to Login | Headless WP 》將 WordPress 完全作為 CMS(無頭 WordPress)是一個可行的選擇,適合使用 React JS 或 Angular JS 等技術完全建構前端的網絡應用程序的人。, 這樣做使前端(...。