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

rest api - WP API querying a custom post type and a custom field

programmeradmin1浏览0评论

I'm developing a site that displays results from a local running race from the past 15 years or so.

I have a custom post type called result with several custom fields.

Each result looks like:

result: { year, position, name, guntime, chiptime, class, classplace}

The results look like this:

I'm pulling in these results via a live-search interface that fetches from wp-json/wp/v2/result?search=SEARCH_TERM

So /wp-json/wp/v2/result?search=colin gets me all of the Colins in my data.

I have two questions about my setup:

  1. How do I add a custom field to search on in my query? IE: I want everyone named Colin who ran in 2018. I've read that that the filter param was removed before the plugin was merged, so looks like that won't work. I think It used to be as simple as filter[year]=2018, but that approach is no longer possible.
    1. I'm wondering more broadly if this whole setup will standup to any real-world traffic. I've got my live-search input debounced, but I'm still going to be doing a ton of api requests. Good news: There is no post content to search through (all the fields are just numerical data). Bad News: I'm still searching about 50,000 post titles looking for matches each time I live-search.

Advice greatly appreciated! Thank you for your time!

发布评论

评论列表(0)

  1. 暂无评论