1

I am working on an application using the WP REST API to display data. I need to be able to search through data entered as a custom field. (I am using Advanced Custom Fields). I have expanded the REST API so that I can grab custom fields using the API. Now I need to include those fields within the searchable data for the post.

I want to search through an HTTP request:

http://example.com/wp-json/posts?type[]=post&filter[posts_per_page]=5&filter[s]=searchterm

In the above example, searchterm is the term that is being searched for. The above request works, but it will only search within title and content. So if searchterm is within either of those, then the search works but if searchterm is within a custom field then the search does not work.

Is there a way that I can expand the search function of the REST API so that I can search through custom fields?

Thanks!

2
  • Hi! Have you ever found a solution to this question? Commented Jul 5, 2016 at 10:33
  • @spik3s I was able to find a workaround for this that seems to have worked for V1 of the REST API. See my answer below. Commented Jul 21, 2016 at 15:32

1 Answer 1

1

I was able to fix this for the REST API V1 by using the Search Everything plugin - https://wordpress.org/plugins/search-everything/.

Sign up to request clarification or add additional context in comments.

Comments

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.