Obtener título del post con enlace

15 abr 2014, 13:53:56
Vistas: 14.2K
Votos: 3

Estoy usando este código para enviar un correo desde mi sitio de WordPress. Envía los enlaces permanentes de los posts. ¿Cómo puedo editarlo para que muestre títulos con enlaces en lugar de solo los enlaces permanentes?

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', 'Notificación de nuevo proyecto', $link);
                //wp_mail('lijb@stunningtech.com', 'Notificación de nuevo proyecto', $message, $headers);
                wp_mail($email, 'Notificación de nuevo proyecto', $message, $headers);
            }
0
Todas las respuestas a la pregunta 1
2

¿Lo usaste así?

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

para usarlo así

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

Intenta usar eso mientras estoy codificando tu código.

15 abr 2014 14:18:40
Comentarios

¿Tuviste la oportunidad?

yeshansachithak yeshansachithak
15 abr 2014 14:41:47

@Ahmad Buen hombre. Que tengas un buen día. :-) :-D :-)

yeshansachithak yeshansachithak
16 abr 2014 07:40:01