3

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);
            }

1 Answer 1

4

Did you use it like that??

<a href="<?php get_permalink($id); ?>"><?php the_title($id); ?></a>

for use to that

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

Try to use that while I'm coding your code.

2
  • Did you have a chance? Commented Apr 15, 2014 at 11:41
  • @Ahmad Good man. Have a good day. :-) :-D :-) Commented Apr 16, 2014 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.