Skip to content

Instantly share code, notes, and snippets.

@hansspiess
Created August 17, 2012 14:28
Show Gist options
  • Save hansspiess/3379145 to your computer and use it in GitHub Desktop.
Save hansspiess/3379145 to your computer and use it in GitHub Desktop.
Wordpress: Add custom Class to Contact Form 7 <form> tag
<?php
add_filter( 'wpcf7_form_class_attr', 'custom_custom_form_class_attr' );
function custom_custom_form_class_attr( $class ) {
$class .= ' nice';
return $class;
}
?>
@cinghaman
Copy link

if i have more than 2 forms ? how to target it

@anaspk
Copy link

anaspk commented Jan 24, 2015

I am also interested in knowing some way to add a class to only a specific form, when there are multiple forms created.

@INDIAN2020
Copy link

Please check this link: http://contactform7.com/faq/can-i-add-id-and-class-attributes-to-a-form-element/
This will give you overall information what you want.

Form specific:
[contact-form-7 id="1234" title="Contact form 1" html_id="contact-form-1234" html_class="form contact-form"]
Field specific:
[text* first-name class:full class:field placeholder "FIRST NAME"]

@zohaib304
Copy link

zohaib304 commented Nov 2, 2019

Add class to submit button,
[submit class:btn class:btn-primary "Send"]

@jasson112
Copy link

Please check this link: http://contactform7.com/faq/can-i-add-id-and-class-attributes-to-a-form-element/
This will give you overall information what you want.

Form specific:
[contact-form-7 id="1234" title="Contact form 1" html_id="contact-form-1234" html_class="form contact-form"]
Field specific:
[text* first-name class:full class:field placeholder "FIRST NAME"]

Ty ! it works for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment