I'm making a query to encode in JSON a bunch of wordpress post data in this way:
$query = new WP_Query( $args );
$posts = $query->get_posts();
foreach( $posts as $post ) {
$output[] = array( 'id' => $post->ID, 'title' => $post->post_title, 'count' => $post->custom_total_hits, 'soundcloud_url' => $post->soundcloud_song, 'soundcloud_id' => $post->soundcloud_ids);
}
echo json_encode($output);
But how can I add to my JSON also the permalink of the $post->ID and the url of the attached image? In order to have something like:
{
"id":28197,
"title":"Hazel English - More Like You",
"count":"000000421",
"soundcloud_url":"https:\/\/soundcloud.com\/hazelenglish\/hazel-english-more-like-you-2",
"soundcloud_id":"317317206",
"link":" ",
"image_url":" "
}