In this lesson, we will explore the /wp-json
route and some of the default functionality.
WordPress gives us a lot of options and data to work with right away. The number of routes available can be overwhelming but we will be focusing on the /wp/v2
routes available. There are a number of routes that involve posts and individual posts including revisions and autosaves. As well as similar routes for pages, tags, and taxonomies.
You'll want to continue to explore the /wp/v2
routes available to you.
Instructor: [0:00] By default, every new WordPress install comes with a WP JSON route ready setup and installed. Here, I'm querying WP JSON. I get a description of all the routes that are available. We start with information about the site with escaped, forward slashes.
[0:18] We see the first route is this one, which is just forward slash. Now, as we scroll down, we can see that there's no oembed/1.. There's no available oembed/1./embed. I can see there's lots of routes that are defined throughout this. What we care about is the WP version 2.
[0:35] With this, we're able to find out about posts. We're able to find out about individual posts. We're able to work with revisions of individual posts. We're able to work with individual revisions of individual posts. We're able to think about auto saves. We're able to think about individual auto saves of individual posts.
[0:59] We're able to think about pages and all the same kinds of things for pages, for tags, and for taxonomies, which are built-in functions of WordPress.
[1:10] We get the methods. We can GET, POST, PUT, PATCH and DELETE in this page's route, but for some we can only GET, for others we can PUT, for others we can only DELETE. This RESTful API is really well documented. We can see the different arguments. We can see the context. We can see lots of different information.
[1:30] Every route that we use is also well documented. Let's check out the posts for it, /wp/v2/posts. Here I've got a list of all the posts that are currently in my instance, there's two of for us to look at pages, all the pages, tags, I have no tags yet, and taxonomies. I have two taxonomies. I've got the categories taxonomy, and I have the tags taxonomy.