わかりました、これは長い答えになるでしょう:)
1.commnets.phpを作成し、次のコードを追加します。
<?php if ( post_password_required() ): ?>
<p class="nopassword"><?php _e( 'This post is password protected. Enter the password to view and post comments.' , 'override' ); ?></p>
<?php
return;
endif;
?>
<?php if(!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) : ?>
<?php die('The comments template cannot be accessed outside of an entry. Nice try!'); ?>
<?php endif; ?>
<?php
$required_text='';
$aria_req='';
?>
<?php $args = array(
'id_form' => 'commentform',
'id_submit' => 'submit',
'title_reply' => __( 'Leave a Reply' ),
'title_reply_to' => __( 'Leave a Reply to %s' ),
'cancel_reply_link' => __( 'Cancel Reply' ),
'label_submit' => __( 'Post Comment' ),
'comment_field' => '<br/><p class="comment-form-comment"><label for="comment">' . _x( 'Comment post', 'noun' ) . '</label><br/><textarea id="comment" name="comment" cols="45" rows="8"></textarea></p>',//Removed from textarea aria-required="true" HTML5 fix
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '</p>',
'comment_notes_after' => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), '<br/><code>' . allowed_tags() . '</code>' ) . '</p>',
'fields' => apply_filters( 'comment_form_default_fields', array(
'author' => '<div class="commnet_text_wrapper"><p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'override' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input class="author" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'override' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input class="email" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website', 'override' ) . '</label>' . '<input id="url" class="website" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p></div>' ) ) );
?>
<?php comment_form($args); ?>
<ol class="commentlist">
<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
</ol>
<div class="paginate-com">
<?php paginate_comments_links(
array('prev_text' => __('‹ Previous comment','override'), 'next_text' => __('Next commnet ›','override'))
); ?>
</div>
そのファイルをテーマのルート ディレクトリ (テーマのindex.phpがある場所) にアップロードします。
2. functions.phpを開き、次のコードを追加します。
// Enable CUSTOM "REPLY" COMMENT FORM so we can style it
function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
<br/><?php printf(__('<span class="saywrap"><span class="fn">%s</span> <span class="says">says:</span></span>','override'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<?php comment_text() ?>
<div class="comment-meta commentmetadata"><a class="commentlink" href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s','override'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)','override'),' ','' );
?>
</div>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
3.テーマのルートディレクトリ内にもあるsingle.phpファイルを見つけて、次のようにcommnetフォームを呼び出します。
<div class="comments-template">
<?php comments_template(); ?>
</div>