Query String Filtering API
Currently, I'm working on a search application that searches/filters stores(Custom Post Type) based on the store-feature(Custom Taxamonies) IDs. When I use the WordPress Fetch API, I can get the full set of Custom Post Type data without any problems. The issue is the query string I've been trying to build. I'm essentially trying to make the query string filter by an AND instead of an OR.
Example:
- Store One store-features: 55 AND 96
- Store Two store-features: 55
- Store Three store-features: 96
The query string needs to only return Store One since it contains both IDs(AND). It cannot return Store Two or Store Three just because it contains either of those IDs(OR). Below are some examples that I have tried so far.
http://localhost/my-site-name/wp-json/wp/v2/locations/?store-features=55store-features=96
http://localhost/my-site-name/wp-json/wp/v2/locations/?store-features=55+96
Note: The query string is built by the 50 checkboxes on the front-end that correspond to the store-features.
[{
id: 1,
name: store 1,
store-features: [
55,
53,
61,
64,
66,
68,
73,
74,
79,
80,
81,
85,
87,
88,
89,
90,
91,
92,
93,
96,
98
]
}, {
id: 2,
name: store 2,
store-features: [
54,
55,
53,
63,
64,
66,
68,
73,
74,
76,
79,
81,
84,
85,
87,
88,
89,
90,
91,
92,
93,
98
],
}, {
id: 3,
name: store 3,
store-features: [
53,
61,
64,
66,
68,
73,
74,
79,
80,
81,
85,
87,
88,
89,
90,
91,
92,
93,
96,
98
]
}]
Thanks, Sean
Topic rest-api query-string jquery plugin-development Wordpress javascript
Category Web