我正在使用此代码从我的wordpress网站发送电子邮件。它发送永久链接的帖子。我如何编辑这个链接标题,而不仅仅是永久链接;
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);
}
最合适的回答,由SO网友:yeshansachithak 整理而成
你是这样用的吗??
<a href="<?php get_permalink($id); ?>"><?php the_title($id); ?></a>
为了使用它
foreach($ids as $id){
$link = get_permalink($id);
$title = get_the_title($id);
$links .= \'<a href="\'.$link.\'">\'.$title.\'</a>\'.\'<br/>\' ;
//$links .= $link . \' <br>\';
}
get_permalink
get_the_title
在我编写代码时尝试使用它。