【发布时间】:2021-09-12 23:17:21
【问题描述】:
大家好,感谢您的宝贵时间。我是
fetching all the Posts,使用categories=参数如下:
https://recipes.turboweb.online/wp-json/wp/v2/posts?categories=2
这里的类别 ID 是
2。因此,它为我获取了包含 CategoryId 2 的所有帖子。但是,此请求不会获取Comments和AuthorName以及更多所需的数据。
我知道通过在普通查询中使用
_embed,我们可以在一个查询中获取所有数据,从而节省时间和资源。这是查询的样子:
https://recipes.turboweb.online/wp-json/wp/v2/posts?_embed
这是输出:
我的问题是如何在按特定 CategoryID 获取帖子时在参数中使用
_embed?用更简单的术语来说,我如何在下面的查询中插入_embed参数?
https://recipes.turboweb.online/wp-json/wp/v2/posts?categories=2
【问题讨论】: