I have the following function which I use to show the author name,author avatar and the author biography in a div. I need to show the title of the latest post by the author along with this. Can anyone help?
function ajaxified_function()
{
$response = new WP_Ajax_Response();
$id = $_POST['author_id'];
$auth_name = get_the_author_meta('display_name', $id);
$avatar = get_avatar($id);
$desc = get_the_author_meta('description',$id);
$auth_desig = get_the_author_meta('designation', $id);
$output = "<div id='bloggers_title'>$auth_name</div>n
<div id='bloggers_desig'>$auth_desig</div>n
<div id='bloggers_avatar'>$avatar</div>n
<div id='bloggers_desc'>$desc</div>n";
$response->add(array(
'what' => 'has',
'data' => $output
));
$response->send();
}
You can get the latest post of an author adding the following code to your function:
Then modify your
$output
, adding the data you need (specificallyguid
for the permalink, andpost_title
for the title), for example: