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
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
Share Improve this question asked Jan 7, 2020 at 13:40 ricardoriosricardorios 1538 bronze badges 3- 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 Commented Jan 7, 2020 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 Commented Jan 7, 2020 at 15:44
- I think this answer basically would cover what you're trying to do with a little tweaking – brianjohnhanna Commented Jan 8, 2020 at 14:12
1 Answer
Reset to default 1I found this plugin that made my life easier, so I didn't have to code all that
https://wordpress/plugins/wp-rest-filter/