內容簡介
REST API 搜尋
僅適用於 REST API 外掛的第 2 版本
這個外掛提供了在 WordPress REST API 中缺失的搜尋功能。
當前 REST API 第 2 版本的問題是,你只能基於每個文章類型搜尋。
/wp-json/wp/v2/posts?filter[s]=apples
/wp-json/wp/v2/pages?filter[s]=apples
這個外掛的功能
為除了修訂版本和設為「exclude_from_search」的類型的所有文章類型添加搜尋功能。
/wp-json/wp/v2/search/apples
如果是多個單字,只需用加號取代空格。
/wp-json/wp/v2/search/apples+pears
還可輕鬆翻頁
第 2 頁:
/wp-json/wp/v2/search/apples+pears/2
第 3 頁:
/wp-json/wp/v2/search/apples+pears/3
Github
外掛標籤
開發者團隊
原文外掛簡介
REST API Search
This is only for Version 2 of the REST API Plugin
This adds the missing functionality of Search into the WordPress REST API.
The issue being with the current REST API Version 2, you can only search on a per post_type basis.
/wp-json/wp/v2/posts?filter[s]=apples
/wp-json/wp/v2/pages?filter[s]=apples
What this plugin does.
Adds the search functionality for all posts types except revisions and types with ‘exclude_from_search’ set to true.
/wp-json/wp/v2/search/apples
In case of a multi word string, just replaces the spaces with plus signs.
/wp-json/wp/v2/search/apples+pears
Also adds easy paging
page 2:
/wp-json/wp/v2/search/apples+pears/2
page 3:
/wp-json/wp/v2/search/apples+pears/3
Github
