WordPress REST API v2 Examples

Here are a few examples on how to use Wordpress REST API v2 First of all Download and Install the plugin just like any other wordpress plugin Get list of posts [crayon-5996a82872a53245873228/] Get list of pages [crayon-5996a82872a5e757453543/] Wordpress REST API for Custom Posts Prerequisite: REST API support needs to be added to custom posts while registering the custom post. Below parameters add the necessary support. For detailed instruction please refer Adding REST API support to Custom Post Types Suppose we have a Custom Post Type news, below parameters would add the necessary REST support to the Custom Post Type [crayon-5996a82872a62756099614/] show_in_rest This allows the Custom post type to be accessed through the REST API rest_base => Optional Parameter This allows to change the REST API route. For e.g. if the custom post type is news. We can define a custom route to access the books post using rest_base parameter e.g. news_api rest_controller_class This is only required to be changed if you are using a custom namespace i.e. other than wp/v2 Once the necessary support is added as shown above the Custom...
Read More