Skip to content

Instantly share code, notes, and snippets.

@abijlani
Created March 2, 2013 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abijlani/5072444 to your computer and use it in GitHub Desktop.
Save abijlani/5072444 to your computer and use it in GitHub Desktop.
The method within core.php of the JSON API plugin for Wordpress. The core.php file is located within "json-api/controllers"
public function get_recent_summary() {
global $json_api;
$posts = $json_api->introspector->get_posts();
$output = array();
foreach ($posts as $post){
$post_summary["id"] = $post->id;
$post_summary["url"] = $post->url;
$post_summary["title"] = $post->title;
$post_summary["date"] = $post->date;
$post_summary["author"] = $post->author->name;
$post_summary["thumbnail"] = $post->attachments[0]->images["thumbnail"]->url;
$output[] = $post_summary;
}
return $this->posts_result($output);
}
@elijahmurray
Copy link

You rock!

@petej830
Copy link

petej830 commented Apr 9, 2013

Thanks. This this helped me out big time!

@baldi-baldi
Copy link

Just perfect! thanks

@justdan0227
Copy link

how do you do this if you have to login first before the json api will return the data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment