如何使用REST api从特定类别发布帖子
问题描述:
I am using rest API to get the post from a specific Category.
but from this URL http://example.com/wp-json/wp/v2/categories/?slug=category_name
I am only getting the category name, not the post.
and by using this link
I am getting all the post but not getting the featured image in that post.
note: I am using the better-featured image
我正在使用rest API从特定类别中获取帖子。
但是来自此URL 并使用此链接 strong> p>
查看此链接 p>
我收到了所有帖子但没有收到该帖子中的精选图片。 p>
注意:我使用功能更强大的图片 strong> p>
div> http: //example.com/wp-json/wp/v2/categories/?slug=category_name code>我只获取类别名称,而不是帖子。 p>
答
You should use filter
to get posts by specific category.
By Category Id:
http://example.com/wp-json/wp/v2/posts?filter[cat]=$cateID
By Category Name:
http://example.com/wp-json/wp/v2/posts?filter[category_name]=$categoryName