Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

V2 API Backbone client - get custom post types #1299

@joneslloyd

Description

@joneslloyd

Hi there,

I'm trying to get custom post types via the javascript client in the V2 API.

When I try this code:

self.events = new wp.api.collections.Posts;

        self.events.fetch({
            data: {
                type: 'event',
                context: 'view',
                filter: {
                   nopaging: true
                }
            }
        }).done( function() {
            self.events.each( function( an_event ) {
                console.log( an_event.attributes );
            });
        });

Nothing happens.

However if I change it to (for testing purposes) use (say) Pages:

self.events = new wp.api.collections.Pages;

        self.events.fetch().done( function() {
            self.events.each( function( an_event ) {
                console.log( an_event.attributes );
            });
        });

It works correctly.

Do you know how I can retrieve custom post types via the WP-API V2 javascript api? (Or if it's possible).

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions