WordPress.org

Ready to get started?Download WordPress

Forums

JSON API
Querying multiple custom post types (2 posts)

  1. Jonathan Sutcliffe
    Member
    Posted 1 year ago #

    note: This is more of a suggestion (or request for confirmation that I'm not doing something insane) than an issue.

    I wanted to be able to query multiple custom post types, and couldn't see an easy way to do that. What I've done to solve this is edit the check on post_type in set_posts_query (singletons/introspector.php) to take a comma-separated array (e.g. a querystring parameter like post_type=hangers,cups,toys).

    if ($json_api->query->post_type) {
        $query['post_type'] = explode(',',$json_api->query->post_type);
    }

    Is this sane? Is there a way to do it without hacking introspector.php? I don't generally like modifying plugin code because it's a maintenance headache.

    http://wordpress.org/extend/plugins/json-api/

  2. Andrew Martin
    Member
    Posted 1 year ago #

    Thank you for this!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.