我想在url中获取wpApi中的数据我正在使用像这样的搜索
https://www.digitemb.com/wp-json/wp/v2/posts?_embed&?filter[order]=DESC&filter[posts_per_page]=5&search=digitize&page=1
我的问题是如何从特定类别获取帖子数据。我不想获得我使用此逻辑的所有类别的数据
search(keyword,id){
return this.http.get("https://www.digitemb.com/wp-json/wp/v2/posts?_embed&?filter[order]=DESC&filter[posts_per_page]=5&search=" + keyword + "&page="+id)
.map(data => data.json());
}
但是这些数据可以获得我想要特定类别帖子的所有类别!
答案 0 :(得分:0)
使用类别的ID来取回该类别中的所有帖子。
http://www.example.com/wp-json/wp/v2/posts?categories=category-ID
可用参数列表 - https://developer.wordpress.org/rest-api/reference/posts/#arguments