Ottenere il titolo del post con link

15 apr 2014, 13:53:56
Visualizzazioni: 14.2K
Voti: 3

Sto utilizzando questo codice per inviare email dal mio sito WordPress. Attualmente invia i permalink dei post. Come posso modificarlo per avere titoli cliccabili invece dei soli permalink?

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('ehmudroy@gmail.com', 'New project notification', $link);
                //wp_mail('lijb@stunningtech.com', 'New project notification', $message, $headers);
                wp_mail($email, 'New project notification', $message, $headers);
            }
0
Tutte le risposte alla domanda 1
2

L'hai usato in questo modo??

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

per utilizzarlo in questo

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

Prova a usarlo mentre sto codificando il tuo codice.

15 apr 2014 14:18:40
Commenti

Hai avuto l'opportunità?

yeshansachithak yeshansachithak
15 apr 2014 14:41:47

@Ahmad Bravo. Buona giornata. :-) :-D :-)

yeshansachithak yeshansachithak
16 apr 2014 07:40:01