Reputation: 36
I'm modifying the WP JSON API core to return just the post titles from a query result object, rather than all the other data.
$posts = $json_api->introspector->get_posts($query);
$post_titles = array();
foreach ($posts as $post){
$post_titles[] = $post; //result: {id:0, type:"post", title:"the title" ..}
$post_titles[] = $post['title']; //fail
}
When using gettype($posts)
I get 'object', and I thought that $obj['key'];
is how to get an object's property in PHP. Any help appreciated, thanks.
Upvotes: 0
Views: 244