您可以使用类似于genesissnippets.com上概述的方法。基本上你想删除genesis_default_list_comments
动作,并用你自己的替换它:
remove_action( 'genesis_list_comments', 'genesis_default_list_comments' );
add_action( 'genesis_list_comments', 'my_list_comments' );
然后在您的my_list_comments
函数中,调用您的评论回调函数。基本上我完全复制了 genesis_default_list_comments 函数,只将回调函数名称更改为我自己的:
function my_list_comments() {
$defaults = array(
'type' => 'comment',
'avatar_size' => 48,
'format' => 'html5',
'callback' => 'my_comment_callback', // <-- this is the change
);
$args = apply_filters( 'genesis_comment_list_args', $defaults );
wp_list_comments( $args );
}
然后在你的my_comment_callback
是你改变评论输出的地方。
function my_comment_callback( $comment, array $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<?php do_action( 'genesis_before_comment' ); ?>
<div class="comment-header">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, $args['avatar_size'] ); ?>
<?php /**** PUT YOUR CHANGES HERE... ****/ ?>
<?php printf( __( '<cite class="fn">%s</cite> <span class="says">%s:</span>', 'genesis' ), get_comment_author_link(), apply_filters( 'comment_author_says_text', __( 'says', 'genesis' ) ) ); ?>
</div>
<div class="comment-meta commentmetadata">
<?php /**** OR HERE! ****/ ?>
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s', 'genesis' ), get_comment_date(), get_comment_time() ); ?></a>
<?php edit_comment_link( __( '(Edit)', 'genesis' ), '' ); ?>
</div>
</div>
<div class="comment-content">
<?php if ( ! $comment->comment_approved ) : ?>
<p class="alert"><?php echo apply_filters( 'genesis_comment_awaiting_moderation', __( 'Your comment is awaiting moderation.', 'genesis' ) ); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div>
<?php do_action( 'genesis_after_comment' );
//* No ending </li> tag because of comment threading
}