Skip to content

Instantly share code, notes, and snippets.

@lizardking8610
Forked from abijlani/core.php
Created May 16, 2018 20:30
Show Gist options
  • Save lizardking8610/6117e19ca969fc90ab35d2bf10b8925c to your computer and use it in GitHub Desktop.
Save lizardking8610/6117e19ca969fc90ab35d2bf10b8925c 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment