Implementing REST API and JavaScript with taxonomies

Now that we have covered how to perform HTTP requests and query our database using REST API, it is time to implement it. We will now be focusing on implementation of REST API and JavaScript with taxonomies in WordPress.

How to send GET requests for taxonomies

In WordPress, you can query for posts by taxonomy. Alternatively, you can also list terms in taxonomy for a given post.

It is fairly easy and is just a matter of few HTTP requests.

To get posts from a given category, we pass the parameter category_name. For example, for the category sample, we will pass the request as follows:

sample_url( 'wp/v2/posts?filter[category_name]=sample' ); 

Similarly, to get posts with a given tag, use the tag parameter. ...

Get Learning WordPress REST API now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.