3

I am using JSON API plugin to query wordpress from a mobile app.

Currently I have a theme on my wordpress site which works as a directory returning "near me" results when a search is made. This is done using a custom search function builtin in the theme.

The function uses custom parameters to get the lat/lon of the user and compare it to the lat/lon of each place in the wp database to sort results by distance.

The issue I am having is that when I run the get_search_results method from the JSON API plugin the custom parameters are ignored.

Does anyone know if there is anyway I can extend the plugin to return the same results the theme is returning when performing a search.

The plugin seems to have a way to extend controllers, but I can't seem to get my head around on how to use that to customize the search query.

Any tip putting me in the right direction will be appreciated.

Thanks!

1
  • 1
    Plugins are off-topic. – Omar Tariq Jun 7 '15 at 12:45
2

I think it is better that you switch to the current beta, version 2, publish on github. This version is much better in possibilities and performance.

In this version it is possible that you get a result for the search term, Iike GET /wp-json/wp/v2/posts?s=awesome.

3
  • Hi! thanks, per the docs it looks similar to v1 for the search method. It seems there is a way to create a custom method which will accept my custom parameters, but I can't find a way. I will keep digging. Thanks again. – JordanBel Jun 8 '15 at 15:54
  • You can enhance the endpoints. The WP API have filter, like json_prepare_{type}, for this requirement. See in the documentation or also in my github account for examples, currently two repos. – bueltge Jun 9 '15 at 10:15
  • Thanks, thay definetely will work. I have to learn how to implement it with my code, but it looks like what I need. Thanks a lot. – JordanBel Jun 9 '15 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.