masonitedoors/searchwp-api-route
Composer 安装命令:
composer require masonitedoors/searchwp-api-route
包简介
Adds an endpoint to the WordPress REST API for searching via SearchWP.
README 文档
README
SearchWP API
Adds an endpoint to the WordPress REST API for searching via SearchWP -- the best tool for improving the usefulness and performance of WordPress search.
This plugin is a free plugin by CalderaWP. It is not an official add-on for SearchWP and is no way associated with SearchWP or the National Football League.
- Requires WordPress REST API (WP-API) 2.0-beta9 or later or WordPress 4.4 or later.
- Requires SearchWP Version 2.6 or later
Technically will work without SearchWP, but queries will run through WP_Query.
Example Queries
For a complete list of possible queries, see: https://calderawp.com/doc/searchwp-api-queries/
wp-json/swp_api/search?s=jedi&engine=star-warswp-json/swp_api/search?&tax_query[field]=slug&tax_query[taxonomy]=categories&tax_query[terms]=1wp-json/swp_api/search?meta_query[key]=jedi&meta_query[value]=luke&tax_query[compare]=IN
Other Post Types
- Added in version 1.2.0 By default query is against posts, to query against the post type "jedi" use:
-
wp-json/swp_api/search?s=rey&post_type=jedi
Multiple Meta Queries
Nested meta queries added in version 1.1.0 and allow for querying by multiple meta fields. Be sure to see the relevant section of the WP_Query docs
Simple Nested Query
Use a [] to create a basic nested query. Default meta_relation is AND. Default compare is IN.
Example: Search where jedi field is "luke" and sith field is "vader".
URL String: /wp-json/swp_api/search?meta_query[key][]=jedi&meta_query[value][]=luke&meta_query[key][]=sith&meta_query[value][]=vader
Translates to:
'meta_query' => array ( 'relation' => 'AND', array ( 'key' => 'jedi', 'value' => 'luke', 'compare' => 'IN', ), array ( 'key' => 'sith', 'value' => 'vader', 'compare' => 'IN', ), )
Relationships Between Query Parts
Use variable meta_relation to change relationship been queries. Also, you can set compare, like with regular meta_queries. Make sure your compare argument is in the right order.
Example: Search where jedi field is "luke" or sith field is not "vader".
URL String wp-json/swp_api/search?meta_query[key][]=jedi&meta_query[value][]=luke&meta_query[compare][]=in&meta_query[key][]=sith&meta_query[value][]=vader&meta_query[compare][]=NOT%20IN&meta_relation=OR
Translates to:
'meta_query' => array ( 'relation' => 'OR', array ( 'key' => 'jedi', 'value' => 'luke', 'compare' => 'IN', ), array ( 'key' => 'sith', 'value' => 'vader', 'compare' => 'NOT IN', ), )
Multiple Values In A Query Part
Put multiple fields into your query parts, by adding extra nesting levels in URL string. Order gets very tricky, numbers (remember to start at 0) help, as shown below.
Example: Search where jedi field is "luke" or "obi-wan" and sith field is not "vader".
URL STRING: wp-json/swp_api/search?meta_query[key][]=jedi&meta_query[value][0][]=luke&meta_query[value][0][]=obi-wan&meta_query[compare][]=in&meta_query[key][]=sith&meta_query[value][]=vader&meta_query[compare][]=NOT%20IN&meta_relation=AND
array ( 'relation' => 'AND', array ( 'key' => 'jedi', 'value' => array ('luke', 'obi-wan' ), 'compare' => 'IN', ), array ( 'key' => 'sith', 'value' => 'vader', 'compare' => 'NOT IN', ), )
License & Copyright
-
Copyright 2015 Josh Pollock for CalderaWP LLC.
-
Licensed under the terms of the GNU General Public License version 2 or later.
-
Please share with your neighbor.
masonitedoors/searchwp-api-route 适用场景与选型建议
masonitedoors/searchwp-api-route 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 979 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「wp-api」 「wp-json-api」 「searchwp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 masonitedoors/searchwp-api-route 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 masonitedoors/searchwp-api-route 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 masonitedoors/searchwp-api-route 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Exposes Advanced Custom Fields Endpoints in the WordPress REST API
WordPress API client for WP-API v2
Get wordpress nav menus and share the main site menus with the child sites.
Base plugin/classes/functionality for creating shortcodes.
Provides UI for connecting to Quickbooks Online over OAuth.
Helper class for connecting from one WordPress installation to another via the WordPress REST API and OAuth.
统计信息
- 总下载量: 979
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: gplv2
- 更新时间: 2020-01-17