I want to get data in wp Api using search keyword

555 views Asked by At

I want to get data in wpApi in url i am using search like this

https://www.digitemb.com/wp-json/wp/v2/posts?_embed&?filter[order]=DESC&filter[posts_per_page]=5&search=digitize&page=1

My Question is that How do i get posts data from specific categories. i don't want to get data of all categories i use this logic to

   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());
          }

but this data can get all categories i want specific categories posts !

1

There are 1 answers

0
Tomislav Stankovic On

Use the ID of the category to get back all posts from that category.

http://www.example.com/wp-json/wp/v2/posts?categories=category-ID

List of available arguments - https://developer.wordpress.org/rest-api/reference/posts/#arguments