Join Morten Rand-Hendriksen for an in-depth discussion in this video Craft the API URL request, part of WordPress REST API (WP-API): First Look (2015).
- The first step in this process has nothing to do…with building the plugin itself.…Before we do anything else, we need to…figure out what our API request URL is going to look like.…As I explained in the previous movie,…we're asking the API to give us the…five most recent posts from any…of the categories the current post is filed under.…And the first step is to figure out exactly…what that URL is going to look like,…and test it to make sure it returns the correct data.…Now, here you'll run into a little bit of a roadblock…if you, like me, are using the theme unit test data.…
That's because out of the box,…the theme unit test data doesn't really…use a lot of categories, so the majority…of the posts will be under the same category.…So no matter what post you're on,…you'll keep getting the same posts in the return…and you can't really test it.…To fix this, I've created three new categories:…one called Cat, one called Dog and one called Monkey.…I know it makes no sense,…but it works well for this example.…And I've applied them randomly…
With the WP API, developers can access the data on a WordPress site—such as users, posts, and categories—programmatically. The result is an expansion of the already limitless field of possibilities where theme and plugin development is concerned.
This course is a first look at the WP API: what it is, how to get it running, how to interact with it, what it can do for us, and what we can do with it. Join Morten Rand-Hendriksen, your guide and WordPress guru, as he walks through the tools and major features (such as routes and endpoints) of the WP API, as well as a short project that shows how this new API will be used in real-world workflows.
- Installing the WP API
- Exploring common routes
- Examining WP API output
- Building plugins with the WP API
- Crafting WP API URL requests
- Creating AJAX functions with the WP API