In my last post, I gave you an overview of WP-API. Read through that post if you need a primer on the capabilities of WP-API. For this post, I will offer an example of API usage and how it can benefit site owners by creating more dynamic content. In this post, we will go over creating a comment widget that auto-updates via WP-API without refreshing the page, and how to use AJAX to poll the API for new comments and then display those comments in a sidebar widget. Here’s a gif of the widget in action as it would look in the Twenty Twelve theme: The first thing you will need is to install the WP-API plugin. WordPress has not included this in core yet as it is still in active development. (Make sure it is the correct plugin by Ryan McCue!) Activate the WP-API plugin. There are no settings for this plugin. Visit your site’s API URL ( to verify the API is active and working. If you want to learn more about the API, visit the previous post in this series or peruse the WP-API getting started guide. After you have verified the API is working and returning JSON data, you can install the example project plugin outlined in this post. This is a fully working plugin. You can
Share This