How to get all posts from parent and children categories?

I had the same use case than you — calling WP-API from React — and ran into the same issue. Unfortunately WP-API does not support filtering by parent categories. In order to support it, you could extend the API’s functionality, adding a new filter that will run a tax_query behind the scenes, similar to Faye’s … Read more

Does the REST API (official) support custom post types?

Thanks for the clarification in the comments. The confusion is between the WordPress.com hosted API and the WordPress.org REST API project, which are different. The WordPress.com API was developed by Automattic and is only available for websites hosted on the WordPress.com platform. There’s some overlap in functionality, but that’s not the documentation you’re looking for … Read more

REST API: No route was found matching the URL and request method

It’s because of how you’ve defined the accepted methods: ‘methods’ => ‘\WP_REST_Server::CREATABLE ‘, You shouldn’t have quotes around it. WP_REST_Server::CREATABLE is a string that equals ‘POST’, but by putting quotes around it you’re literally setting the method as ‘\WP_REST_Server::CREATABLE’, which is not a valid HTTP method. You can see this in the response to the … Read more

WordPress 4.7 REST API endpoints

According to ticket #38373 the following endpoints will be supported in version 4.7. Let me quote Rachel Baker: REST API endpoints for your WordPress content. These endpoints provide machine-readable external access to your WordPress site with a clear, standards-driven interface, allowing new and innovative apps for interacting with your site. These endpoints support all of … Read more

WP REST API core major changes

As of WordPress 4.7 now we have the following filter to hook to: $args = apply_filters( “rest_{$this->post_type}_query”, $args, $request ); So if you would like to perform a request like: http://yoursite.com/wp-json/wp/v2/posts?meta_key=your_key&meta_value=your_value&per_page=10 OR http://yoursite.com/wp-json/wp/v2/posts?meta_query[0][key]=your_key&meta_query[0][value]=your_value&per_page=10 you can do it through the following piece of code (within your functions.php): /** * This function will allow custom parameters within … Read more

WP REST API – Multisite – get posts from all sites

Here’s a REST API recipe for latest post per site on a multi-site, for relatively few sites: Use get_sites(), loop over sites and switch to each site, query latest post on each site, collect data, order data by utime, serve data Example REST Routes https://example.com/wp-json/wpse/v1/latest-post-per-site https://example.com/wp-json/wpse/v1/latest-post-per-site?number=10 https://example.com/wp-json/wpse/v1/latest-post-per-site?debug Example Plugin Here’s a demo plugin implementing the … Read more