Un guide de 120 pages pour maîtriser le référencement naturel de WordPress
J'achète le guideAjouter les 5 derniers commentaires de l’auteur
EDIT du 04/07/2012 : code mise à jour grâce à BoiteaWeb
Pour continuer à ajouter du contenu aux pages auteur, on peut ajouter les 5 derniers commentaires de l'auteur.
Copiez ce code tout en haut du fichier author.php :
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
$myid = $curauth->ID;query_posts("author=$myid&posts_per_page=-1");?>
$myid = $curauth->ID;query_posts("author=$myid&posts_per_page=-1");?>
Copiez ensuite dans la page, là où vous désirez faire apparaître le code :
<?php
$comments = get_comments("author_email=$curauth->user_email&number=5");
foreach($comments as $comment) :
$theid = $comment->comment_post_ID;
echo '<blockquote><p>'.$comment->comment_content.'</p></blockquote>
<p>Le '.get_comment_date( 'd F Y', $comment->comment_ID ).' dans <strong><a href="'.get_permalink($theid).'" title="'.get_the_title($theid).'">'.get_the_title($theid).'</a></strong></p><br />';
endforeach;
?>
$comments = get_comments("author_email=$curauth->user_email&number=5");
foreach($comments as $comment) :
$theid = $comment->comment_post_ID;
echo '<blockquote><p>'.$comment->comment_content.'</p></blockquote>
<p>Le '.get_comment_date( 'd F Y', $comment->comment_ID ).' dans <strong><a href="'.get_permalink($theid).'" title="'.get_the_title($theid).'">'.get_the_title($theid).'</a></strong></p><br />';
endforeach;
?>
Plus d'informations sur cet article
Article rédigé par +Daniel Roch.
© 2012 SeoMix
Guide par Daniel Roch & édité par Olivier Andrieu
Design du site par Willy Bahuaud.
Intégration par Daniel sur le CMS WordPress.