Closed pdewouters closed 10 years ago
Unless creating custom routes for custom post types would make it work with the default resource.
I'm also an AngularJS noob, so we can help each other muddle through.
Is the result here different than if you were to use the current resource like so?
wpAPIResource.query( {
param1: 'posts',
type: 'post_type'
} );
I think a $resource
service is perfect for most operations needed for WP-API. Is there anything it can't do for us that $http
can? Perhaps we can add another service using $http
if we find need?
Going to close this as the correct approach is to extend the WP_JSON_CustomPostType
class, as in https://github.com/WP-API/WP-API/blob/master/lib/class-wp-json-pages.php
Don't merge yet
/posts
could be replaced with a placeholderThe WP API doesn't follow a strict RESTful approach to URLs. For example, to get posts from a specific post type, the URL looks like this:
http://local.wordpress.dev/wp-json/posts/?type=my_post_type
With the current implementation of a general resource for all requests, it's not possible to generate these URLs. Here I introduce a separate resource for getting posts and passing a parameter for the post type:
As the
type
parameter has no placeholder, it's converted to a query argument.Disclaimer: I'm an AngularJS noob, so this may not be the ideal approach :) Maybe using the $http would be better as this API is not 100% RESTful?