Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a registerType method to create custom post type shortcuts #52

Merged
merged 4 commits into from
Jun 30, 2014

Conversation

kadamwhite
Copy link
Collaborator

It is not hard to specify a post type request via

wp.posts().type( 'some_cpt' )... // continue with request

However, if you are building an application that relies very heavily on custom types, you may find yourself wanting a convenience method for requesting your own custom type. This PR adds a registerType method to WP instances, which can be used to define a convenience method of that sort:

// Defines a CPT handler `events()` on the current WP instance
wp.events = wp.registerType( 'event_cpt' );

// wp.events() can now be used to specify requests for that custom post type quickly
wp.events().then(function( eventItems ) {
  // Do something with the returned collection of event objects
});

@kadamwhite kadamwhite merged commit 26c2834 into master Jun 30, 2014
@kadamwhite kadamwhite deleted the feature/add-custom-type-endpoint-25 branch June 30, 2014 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant