首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何通过ACF属性查询Wordpress API?

如何通过ACF属性查询Wordpress API?
EN

Stack Overflow用户
提问于 2018-08-05 22:29:34
回答 2查看 2.8K关注 0票数 2

我正在尝试根据ACF属性查询Worpress API。

如果不包含查询,则会得到以下输出:

代码语言:javascript
复制
[{"id":215,"date":"2018-08-05T09:21:37","date_gmt":"2018-08-5T08:21:37","guid":{"rendered":"x"},"modified":"2018-08-05T09:21:37",
"modified_gmt":"2018-08-05T08:21:37","slug":"sasradisson","status":"publish","type":"hotel","link":"https:x",
"title":{"rendered":"SAS Radisson"},"template":"","acf":{"stad":{"value":"barcelona","label":"barcelona"},
"description":"","images":false},"_links":{"self":[{"href":"x"}],"collection":[{"href":"x"}],
"about":[{"href":"x"}],"wp:attachment":[{"href":"x"}],"curies":[{"name":"wp","href":"x","templated":true}]}},
{"id":205,"date":"2018-08-04T11:25:35","date_gmt":"2018-08-04T10:25:35","guid":{"rendered":"x"},
"modified":"2018-08-04T14:22:12","modified_gmt":"2018-08-04T13:22:12","slug":"citybox-oslo","status":"publish",
"type":"hotel","link":"x","title":{"rendered":"Citybox Oslo"},"template":"",
"acf":{"stad":{"value":"oslo","label":"oslo"},"description":"","images":false},
"_links":{"self":[{"href":"x"}],"collection":[{"x"}],"about":[{"href":"x"}],"wp:attachment":[{"href":"x"}],
"curies":[{"name":"wp","href":"x","templated":true}]}}]

(为简洁起见,我将所有urls替换为"x“)

在所有其他属性中,还有ACF属性,如下所示:

代码语言:javascript
复制
"acf":{"stad":{"value":"barcelona","label":"barcelona"}

这些查询都不起作用:

代码语言:javascript
复制
/wp-json/wp/v2/hotels?acf={stad:{value:%27barcelona%27}}

/wp-json/wp/v2/hotels?acf.stad.value=barcelona

如何构建正确的URL查询?

如果这是不可能的,什么是替代的解决方案?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51695215

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档