comment form in single post worked well. then after adding some customization, after posting a comment, it redirects to this link wp_comments_post.php with blank page.
Here is my code in comments.php so what is wrong here to make it work again?
<?php
$form_args = array(
'fields' => array(
'author' => ' <form class="getin_form" id="post-a-comment"> <div class="row"> <div class="col-md-6 col-sm-6"> <div class="form-group bottom35"> <input class="form-control" type="text" placeholder="First Name:" required style=" border: none; border-bottom: 1px solid #a5a5a5; border-radius: 0; padding: 12px 0;box-shadow: none;height: 44px;color: #a5a5a5;font-size: 14px;position: relative; "> </div> </div>',
'email' => ' <div class="col-md-6 col-sm-6"> <div class="form-group bottom35"> <input class="form-control" type="text" placeholder="Email:" required id="email" name="email" style=" border: none; border-bottom: 1px solid #a5a5a5; border-radius: 0; padding: 12px 0;box-shadow: none;height: 44px;color: #a5a5a5;font-size: 14px;position: relative; "> </div> </div> ',
),
// change the title of the reply section
'title_reply'=>'Add Comment',
// remove "Text or HTML to be displayed after the set of comment fields"
'comment_notes_after' => '',
// redefine your own textarea (the comment body)
'comment_field' => ' <div class="col-md-12 col-sm-12"> <div class="form-group bottom35"> <p class="comment-form-comment"><div class="form-group"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><br /> <textarea class="form-control" placeholder="Message" style=" border: none; border-bottom: 1px solid #a5a5a5; border-radius: 0; box-shadow: none; " aria-required="true"></textarea></p> </div></div> ',
'submit_field' =>' <div class="col-sm-12" style="padding-right: 0; padding-left: 0;"> <button type="submit" class="button btnprimary form-control"> submit request </button> </div> </div> </form> </div> </div> </div> </div>',
);
comment_form($form_args);
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There are other issues in your code or the $form_args array items, but the main ones are:
-
The blank page is due to missing hidden comment fields for replying to comments — see
get_comment_id_fields(), where the fields are in thesubmit_fieldarg by default.So to quickly fix that, add
%2$sin that arg like so:'submit_field' => '... <button type="submit" class="button btnprimary form-control"> submit request </button> %2$s ...',But you should actually use the
submit_buttonarg to customize the submit button HTML, then with thesubmit_fieldarg, use something like:'submit_field' => '<div>%1$s %2$s</div>', -
The comment
textareafield needs to have itsnameset tocomment.'comment_field' => '... <textarea class="form-control" placeholder="Message" ... name="comment"> ...', -
Please, make sure your HTML is valid — you’ve got an unwanted
</form>tag in thesubmit_fieldarg. 🙁
I hope that helps and please review the comment_form() reference for details on the other args, and other relevant details/resources.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0