0

The issue

The comment form, as i planned to design it, will use Bootstrap's input groups and probably input addons. Translating in bare coins, the needed markup for each input is like this:

<section class="form-group">
    <input type="text" class="form-control" id="name" placeholder="Your name" />
</section>

Wordpress function comment_form(), as far as i know, doesn't allow this kind of markup. I can give id or classes to the form, to the submit button, but i was not able to find anything that lets me add wrapping elements and classes to inputs.

The question

Since i don't want to write my own function, cause i'm concerned about plugins not being able to function properly, is there a way to do this using as much native functions as possible? Thank you.

EDIT

To avoid any misunderstanding, if not clear, i'm not asking a question about Bootstrap itself, but just how should i generate a precise markup with Wordpress.

3
  • See stackoverflow.com/questions/11333810/…
    – WebElaine
    Commented May 26, 2017 at 14:48
  • @WebElaine And that won't cause issues? After all it is writing a custom function instead of using wp's one Commented May 26, 2017 at 14:53
  • Most sites are customized at least a little, whether it's custom functions or filters. Shouldn't cause issues unless you let the site sit there for 5 years without updating your code to later standards. :)
    – WebElaine
    Commented May 26, 2017 at 15:05

1 Answer 1

1

Yeah this should be possible using the comment_form_default_fields filter, like so:

apply_filters( 'comment_form_default_fields', $fields );

$fields = array( 'name' => '<section class="form-group">
    <input type="text" class="form-control" id="name" placeholder="Your name" />
</section>'
);

Just remember to add any other fields that you want to add into that array too.

2
  • Ok going to try that Commented May 26, 2017 at 14:55
  • Very well, it's working. Commented May 26, 2017 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.