Skip to content

Instantly share code, notes, and snippets.

@pat-eason
Created August 8, 2014 16:35
Show Gist options
  • Save pat-eason/946864984f1a231bac77 to your computer and use it in GitHub Desktop.
Save pat-eason/946864984f1a231bac77 to your computer and use it in GitHub Desktop.
WordPress Comment Walker
//Comment walker
function comments_walker($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>
<br />
<?php endif; ?>
<div class="comment-content-box">
<?php comment_text(); ?>
<div class="comment-content-meta-things">
<?php printf( __( 'Posted by %s' ),get_comment_author_link()); ?>
|
<a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>">
<?php printf( __('%1$s'), get_comment_date()); ?>
</a>
<?php edit_comment_link( __( '(Edit)' ), ' ', '' ); ?>
|
<?php comment_reply_link(array_merge($args,array('add_below'=>$add_below,'depth'=>$depth,'max_depth'=>$args['max_depth']))); ?>
</div>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment