私は現在、独自のWordpressテーマを開発しており、最近カスタムに取り組んでいますcomments_template();
。この方法を使用するwp_list_comments();
ことが、ページ/投稿ごとにコメントを取得して表示するためのベストプラクティスであることを読みました。コメントがそのメソッドを介して取り込まれ、表示される方法を正常にカスタマイズしました。
comment_form();
また、この方法を使用することがコメントフォームを表示するためのベストプラクティスであることも読みました。しかし、私はこれをカスタマイズしようと本当に苦労しています。$ args、filters、actionsの間で少し混乱しています。
基本的に、コメントフォームの一部を大幅に変更したいと思います。comment_form();
メソッドのベストプラクティスを使用しながら、コメントフォームの一部を変更するにはどうすればよいですか?
私が本当にする必要があるのは、既存の<p>
タグのいくつかをでラップすることだけです<divs>
。私が行おうとしている更新のリストは以下のとおりです。
<h3>
ヘッダーを微調整して<h2 class="comments-header">Tell us about you!</h2>
- フォームフィールドを
<fieldset></fieldset>
- ラップ
<label>
イン<div class="label"></div>
- ラップ
<input>
イン<div class="field"></div>
- コメントの後ではなく前に
<p class="form-allowed-tags"></p>
表示する<textarea>
- フォームの送信ボタンを変更して、
<button>
要素ではなく要素を使用する<input>
詳細な説明については、以下のコードを参照してください...
デフォルトのcomment_form(); 出力されるコード:
<div id="respond">
<h3 id="reply-title">Leave a Reply</h3>
<form action="http://localhost/.../wp-comments-post.php" method="post" id="commentform">
<p class="comment-notes">
Your email address will not be published. Required fields are marked
<span class="required">*</span>
</p>
<p class="comment-form-author">
<label for="author">Name</label>
<span class="required">*</span>
<input id="author" name="author" type="text" value="John Doe" size="30" aria-required="true">
</p>
<p class="comment-form-email">
<label for="email">Email</label>
<span class="required">*</span>
<input id="email" name="email" type="text" value="johndoe@dodgeit.com" size="30" aria-required="true">
</p>
<p class="comment-form-url">
<label for="url">Website</label>
<input id="url" name="url" type="text" value size="30">
</p>
<p class="comment-form-comment">
<label for="comment">Comment</label>
<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
</p>
<p class="form-allowed-tags">
You may use these HTML tags and attributes...
</p>
<p class="form-submit">
<input name="submit" type="submit" id="submit" value="Post Comment">
<input type="hidden" name="comment_post_ID" value="22" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</p>
</form>
</div> <!-- #respond -->
私が出力しようとしているコード:
<div id="respond">
<h2 class="comments-header">Tell us about you!</h2>
<form action="http://localhost/.../wp-comments-post.php" method="post" id="commentform">
<fieldset>
<div class="label"><label for="author">Name <span class="required">*</span></label></div>
<div class="field"><input id="author" name="author" type="text" value="<?php echo $comment_author_email; ?>" size="30" aria-required="true"></div>
</fieldset>
<fieldset>
<div class="label"><label for="email">E–mail (will not be published) <span class="required">*</span></label></div>
<div class="field"><input id="email" name="email" type="text" value="<?php echo $comment_author_email; ?>" size="30" aria-required="true"></div>
</fieldset>
<p class="form-allowed-tags">
You may use these HTML tags and attributes...
</p>
<fieldset>
<div class="field"><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></div>
</fieldset>
<p class="form-submit">
<button class="story-submit-btn" type="submit" name="submit" id="sub">Post your story</button>
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
</p>
</form>
</div> <!-- #respond -->
どんな助けでも大歓迎です!