首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >修改创世纪主题评论显示

修改创世纪主题评论显示
EN

Stack Overflow用户
提问于 2013-03-13 19:01:01
回答 1查看 1.7K关注 0票数 0

我需要修改链接(用户名)显示在评论,删除或更改。唯一的困难是,它需要做的创世记框架。在comments.php中,我发现:

代码语言:javascript
复制
do_action( 'genesis_before_comments' );
do_action( 'genesis_comments' );
do_action( 'genesis_after_comments' );

但我不知道如何修改“成因_注释”的内容。

也许应该通过以下方式来完成:

代码语言:javascript
复制
add_action( 'genesis_comments' , 'comments' );
function comments()
{
    //... here is the problem
}
EN

回答 1

Stack Overflow用户

发布于 2013-12-03 03:40:09

您可以使用类似于genesissnippets.com概述的方法。基本上,您希望删除genesis_default_list_comments操作,并将其替换为您自己的操作:

代码语言:javascript
复制
remove_action( 'genesis_list_comments', 'genesis_default_list_comments' );
add_action( 'genesis_list_comments', 'my_list_comments' );

然后在您的my_list_comments函数中,调用您的注释回调函数。基本上,我完全复制了genesis_default_list_comments函数,并且只将回调函数名更改为自己的:

代码语言:javascript
复制
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中更改注释输出。

代码语言:javascript
复制
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

}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15394141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档