Good morning! Is there any way to do searches with the WordPress REST API with custom fields, being more specific, I have some custom posts, with a custom field of a specific date, and I want to do a search of those same posts between two specific dates, and that print the result to me in the JSON that WordPress sends

  • No, WP won't recognize custom field dates as dates that can be searched between. If the custom field has been added to the REST API then you can search for it, but you would need to search for every individual date that's in your desired range. You can pull from the REST API and then use PHP (or whatever language you're using) to search through the data for posts within a date range. – WebElaine Jan 7 at 15:20
  • @WebElaine so I have to do that coding a plugin or in the functions.php? Or just pull all the data and sort it after it? – ricardorios Jan 7 at 15:44
  • I think this answer basically would cover what you're trying to do with a little tweaking – brianjohnhanna Jan 8 at 14:12

I found this plugin that made my life easier, so I didn't have to code all that


| improve this answer | |

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.