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. Commented Jun 7, 2015 at 12:45

1 Answer 1

3

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. Commented Jun 8, 2015 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. Commented Jun 9, 2015 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. Commented Jun 9, 2015 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.