Twenty Fourteenについて
2件の返信を表示中 - 1 - 2件目 (全2件中)
-
まずcomments.phpの41行目からのwp_list_commentsにcallbackを下記のように追記します。
<?php wp_list_comments( array( 'style' => 'ol', 'short_ping' => true, 'avatar_size'=> 34, 'callback'=>'mytheme_comment', ) ); ?>
それからfunctions.phpにつぎのコードを追加してください。
function mytheme_comment( $comment, $args, $depth ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> <<?php echo $tag; ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?>> <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> <footer class="comment-meta"> <div class="comment-author vcard"> <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> <?php printf( __( '%s <span class="says">says:</span>' ), sprintf( '<b class="fn">%s</b>', get_comment_author_link() ) ); ?> </div><!-- .comment-author --> <div class="comment-metadata"> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID, $args ) ); ?>"> <time datetime="<?php comment_time( 'c' ); ?>"> <?php printf( _x( '%1$s at %2$s', '1: date, 2: time' ), get_comment_date(), get_comment_time() ); ?> </time> </a> <?php edit_comment_link( __( 'Edit' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .comment-metadata --> <?php if ( '0' == $comment->comment_approved ) : ?> <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p> <?php endif; ?> </footer><!-- .comment-meta --> <div class="comment-content"> <?php comment_text(); ?> </div><!-- .comment-content --> <div class="sns-buttons"> <!-- たとえばここにSNSシェアプラグインのコード --> </div> <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '<div class="reply">', 'after' => '</div>' ) ) ); ?> </article><!-- .comment-body --> <?php }
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「Twenty Fourteenについて」には新たに返信することはできません。
(@cube999)
10年、 4ヶ月前
こんにちは、よろしくお願いいたします。
Twenty Fourteenと言うテーマをカスタマイズ中です。
ひとつひとつのコメントの下部に、SNSシェアプラグインのコードを入れたいのですが
comments.phpのいろんな箇所に入れてみたところ、表示されません。
single.phpの
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
と言う部分の真下に入れたら表示されたのですが、コメント全体の下にひとつだけ表示されます。
それぞれのコメントの真下(3つコメントがあれば3つ表示される)に表示されるようにするにはどのテンプレートにコードを挿入すればいいのでしょうか?
ご存知の方、どうぞお教えください。
よろしくお願いいたします。