I am using the below code to obtain post information in Wordpress. I have found this code online and have added the two variables "date" and "author". However, these are not currently working as required/expected.
For "date" it is returning the full date/time stamp (i.e 2017-03-08 15:12:39) rather than the nicely formatted date retrieved when using get_the_date(); (i.e 8th March 2017). Can I adjust my markup to format the date?
For "author", nothing at all is being returned?
Thanks in advance.
$postData = get_posts($postParameters);
$posts = array();
foreach($postData as $post) {
$post = array(
"id" => $post->ID,
"title" => $post->post_title,
"excerpt" => $post->post_excerpt,
"date" => $post->post_date,
"author" => $post->post_author,
"slug" => $post->slug,
"image" => array("url" => get_the_post_thumbnail_url($post->ID)),
"link" => get_permalink($post->ID),
"category" => get_the_category($post->ID)[0]->name
);
array_push($posts, $post);
}