jaredb138
Forum Replies Created
-
Sure I would add this:
The REST API – Filter Fields plugin can also filter the results generated from a native WP API filter (or search). For instance, doing
/wp-json/wp/v2/posts?categories=34will return the last 10 posts from the category with the ID of 34.You can use the Filter Fields plugin with queries like this by appending
&fields=<field-name>to the end of that query like/wp-json/wp/v2/posts?categories=34&fields=<field-name>Using
/wp-json/wp/v2/posts?categories=34&fields=idwill return only the id’s of the 10 posts returned by the native category filter.The Filter Fields plugin can also filter the fields of API searches. Doing
/wp-json/wp/v2/posts?search=foo&fields=title,content.rendered(foo being the search term) will return the title and post content of all posts that contain the search term “foo”.It is important to note that the order of parameter queries is not important. You can call the native filter query in the URL first, or you can call the Filter Fields Plugin first.
Simply append the other query with an ampersand. For example:
Using
/wp-json/wp/v2/posts?search=foo&fields=title,content.renderedand
Using
/wp-json/wp/v2/posts?fields=title,content.rendered&search=foowill return the exact same results.
- This reply was modified 8 years, 11 months ago by jaredb138. Reason: formatting