0

コメントに表示されるリンク(ユーザーの名前)を修正、削除、または変更する必要があります。唯一の難点は、Genesis Framework に対して行う必要があることです。私が見つけたcomments.phpで:

do_action( 'genesis_before_comments' );
do_action( 'genesis_comments' );
do_action( 'genesis_after_comments' );

しかし、「genesis_comments」の内容を変更する方法がわかりません。

おそらく、次のようにする必要があります。

add_action( 'genesis_comments' , 'comments' );
function comments()
{
    //... here is the problem
}
4

1 に答える 1

2

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

}
于 2013-12-03T03:40:09.950 に答える