我需要修改链接(用户名)显示在评论,删除或更改。唯一的困难是,它需要做的创世记框架。在comments.php中,我发现:
do_action( 'genesis_before_comments' );
do_action( 'genesis_comments' );
do_action( 'genesis_after_comments' );但我不知道如何修改“成因_注释”的内容。
也许应该通过以下方式来完成:
add_action( 'genesis_comments' , 'comments' );
function comments()
{
//... here is the problem
}发布于 2013-12-03 03:40:09
您可以使用类似于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
}https://stackoverflow.com/questions/15394141
复制相似问题