WordPress comments.php 表示されない
comments.phpが、本の通りに表示されない問題。
参考にさせていただきました。こちらのサイトのほうが良いです。
コメント欄を表示するcomments.phpを作る [WordPressテーマ作成の手順16] | *Web Design 覚え書き*
ポイントは、comment_form( $args ) 引数に配列を渡すところ
comment_form 関数定義
基本、引数には配列を渡す。さらにfields は配列になっている。
これも、配列のまま記載してあげる。 WordPress5.0からは記載しないと動かなかった。
リファレンスはこちら
結論
//引数を用意 <?php $args = array( 'title_reply' => 'Leave a Comment', 'label_submit' => 'Submit Comment', 'comment_notes_before' => '<p class="commentNotesBefore">入力エリアすべてが必須項目です。</p>', 'comment_notes_after' => '<p class="commentNotesAfter">内容をご確認の上、送信してください。</p>', //ここが問題のfieldsの箇所、配列を渡して全て記載する 'fields' => array( 'author' => '<p class="comment-form-author">' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' placeholder="*your name" /></p>', 'email' => '<p class="comment-form-email">' . '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . 'placeholder="*your email" /></p>', 'url' => '', ), 'comment_field' => '<p class="comment-form-comment">' . '<textarea id="comment" name="comment" cols="50" rows="6" aria-required="true"' . $aria_req . ' placeholder="*COMMENT" /></textarea></p>', ); //comment_form を呼び出す comment_form( $args ); ?>