wordpress-query-posts
wordpress-query-posts copied to clipboard
Support for custom post types
I'm using WP REST API Controller to add custom post types (and custom fields) to my Rest API.
So, for example, I can now grab books:http://mysite.com/wp-json/wp/v2/books
instead of just posts: http://mysite.com/wp-json/wp/v2/posts
I modified your code in this fork, so that a postType
parameter can be passed to the QueryPosts
component like so:
e.g.<QueryPosts postType={'book'} query={{search: 'harry potter' }}/>
If the parameter is not provided, it defaults back to using 'posts'.
Thought it could be useful - I'm fairly new to testing and redux so I've wrangled this together in my fork..it works nicely for me, and I'll be building on it. Maybe this could be useful for all.