最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Custom search with Custom Fields in WP REST API?

programmeradmin4浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

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

https://wordpress/plugins/wp-rest-filter/

发布评论

评论列表(0)

  1. 暂无评论