Add custom post type to Backbone collections
I am trying to fetch posts of a custom post type (cpt) with the backbone js client.
I registered the cpt with the show_in_rest param set to true. I enqueued the wp-api script.
The url http://myweb.com/wp-json/wp/v2/custom works.
In the js, this works:
wp.api.loadPromise.done( function() {
var _posts = new wp.api.collections.Posts();
});
but this does not:
wp.api.loadPromise.done( function() {
var _custom = new wp.api.collections.Custom();
} );
saying "wp.api.collections.Custom is not a constructor"
Why?
ps: I registered to cpt like this:
register_post_type('custom', array(
'label' = 'Custom',
'public' = true,
'show_in_rest' = true,
...
));
Topic backbone rest-api custom-post-types Wordpress
Category Web