How to use WordPress REST API v2 to search posts? How to use WordPress REST API v2 to search posts? wordpress wordpress

How to use WordPress REST API v2 to search posts?


I did something similar to what you are describing for a WP/bbPress android/ios app. First, I made my own wordpress search api end point to hit. Then on the wordpress side I used a custom mysql query to query post titles and post content for the search string and return that to the api.

I made the query only return 25 results as I didn't need to have more results than that, with pagination and such.


You can use Search Results REST API Endpoint to seach by keywords you provide.

For example http://yourdomain.com/index.php/wp-json/wp/v2/search?search=lorem&per_page=5&page=1 will search for the keyword lorem in your wordpress posts.

Per_page : limits the number of results per page