WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: JSON API] Querying on multi-site instance (2 posts)

  1. Lounge9
    Member
    Posted 2 years ago #

    How can I get the JSON API to work across a multisite instance?

    I can only get results when I query with a specific post name, like:
    ?json=1&p=314

    URLs that use the API methods, like this: /api/get_post/?id=314
    return this: {"status":"error","error":"Not found."}

    Any help would be greatly appreciated.

    Thanks,
    DouG

  2. pro120
    Member
    Posted 2 years ago #

    I recently needed a solution for this. Here is my fix.

    I added the following lines just below the included files of json-api.php

    if( isset($_GET['siteid']) ) {
    	global $site_id;
    	$site_id = $_GET['site_id'];
    	switch_to_blog($site_id);
    }

    You would just include the site id in your query string like so
    http://example.com/api/?siteid=3&id=43&post_type=attachment

    This was using wordpress 3.2.1

    I don't think the global $site_id declaration was 100% necessary but shouldn't hurt.

Topic Closed

This topic has been closed to new replies.

About this Topic