Last active
December 11, 2015 23:08
-
-
Save siriokun/4674766 to your computer and use it in GitHub Desktop.
Display Comments in Front page #wptips
http://www.deluxeblogtips.com/2013/01/display-comments-in-homepage.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
while ( have_posts() ) : the_post(); | |
if ( have_comments() ) | |
{ | |
echo '<ol class="comment-list">'; | |
wp_list_comments(); | |
echo '</ol>'; | |
} | |
endwhile; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$comments = get_comments( array( | |
'post_id' => get_the_ID(), | |
'status' => 'approve', | |
) ); | |
if ( !empty( $comments ) ) | |
{ | |
echo '<ol class="comment-list">'; | |
wp_list_comments( array( | |
'callback' => 'si_comment_layout', | |
'type' => 'comment', | |
), $comments ); | |
echo '</ol>'; | |
} | |
function si_comment_layout( $comment, $args, $depth ) | |
{ | |
?> | |
<li> | |
<div class="comment-author"> | |
<?php echo get_avatar( $comment, 30 ); ?> | |
</div> | |
<div class="comment-content"> | |
<?php printf( '<cite class="url fn n">%s</cite>', get_comment_author_link() ); ?>: | |
<?php echo strip_tags( get_comment_text() ); ?> | |
</div> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment