The <input>
tags does not allow/support many CSS properties, so I want to change it to <button>
.
How can I get that button and apply a filter to it?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityYou should be able to change the HTML structure for the comment form's submit, with the comment_form_defaults
filter.
Here's an untested example:
add_filter( 'comment_form_defaults', function( $defaults )
{
// Edit this to your needs:
$button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />';
// Override the default submit button:
$defaults['submit_button'] = $button;
return $defaults;
} );
where you adjust the $button
to your needs.
There's also the comment_form_submit_button
filter:
add_filter( 'comment_form_submit_button', function( $submit_button, $args )
{
// Override the submit button HTML:
$button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />';
return sprintf(
$button,
esc_attr( $args['name_submit'] ),
esc_attr( $args['id_submit'] ),
esc_attr( $args['class_submit'] ),
esc_attr( $args['label_submit'] )
);
}, 10, 2 );
It should even be possible with the comment_form_submit_field
filter, but it contains hidden fields as well, so it might not be as helpful as the other filters.
add_filter( 'comment_form_submit_button', function( $submit_button, $args ){}
I would like to use this one. The $submit_button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />';
copied to the second method isn't working.
comment_form_submit_button
filter. @thednp
:before
are not working.