Join Morten Rand-Hendriksen for an in-depth discussion in this video Create condition for featured images, part of WordPress REST API (WP-API): First Look (2015).
- Alright, so we're not quite done…with featured images yet.…You see, although it's really neat…that WordPress provides us with this nice icon,…if there is no featured image…and doesn't just fail dramatically,…it doesn't look very good…so we need to put in a conditional statement…to test whether or not…the featured image actually exists.…Now, you'll remember that for this first object…that has the icon,…if we open it and take a look at the output…from the API, you'll see that the…featured_image field here is set to 0.…Now, this 0 indicates there is no featured image…and we can use this information to exclude…the featured image code if we don't need it.…
Now here's important to think about this the right way,…we could, of course, just provide…nothing in this url when we hit 0,…meaning we'll still put in the figure…on the image tag,…there just won't be an image there,…but that would clutter up our html…with lots of stuff that doesn't need to be there.…So I want to take this entire piece here…from the figure to the end figure…
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