I am using this code to send an email from my wordpress site. It send permalinks of the posts. How can i edit this to have linked titles instead of just permalinks;
if(count($ids) > 0){
$user_id = $usermeta['user_id'];
$userdata = get_userdata($user_id);
$email = $userdata->data->user_email;
//echo $email;
$links = '';
foreach($ids as $id){
$link = get_permalink($id);
$links .= $link . ' <br>';
}
//echo $links;
if (have_posts()) :
while (have_posts()) :
the_post();
$emailTpl = get_the_content();
endwhile;
endif;
$message = preg_replace('/\[\%urls\%\]/', $links, $emailTpl);
$headers = "MIME-Version: 1.0\n" . "Content-Type: text/html;";
//wp_mail('[email protected]', 'New project notification', $link);
//wp_mail('[email protected]', 'New project notification', $message, $headers);
wp_mail($email, 'New project notification', $message, $headers);
}