Skip Navigation

[Resolved] Add class to form

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#626036

Hello,

I would like to add class to the filter form.

Specialy, I would like to add class "form-inline" . Right now i use Jquery to add class, but it isn't a good way.

Thanks a lot.

#626058

Hello,

Yes, it is possible with Views filter hook "wpv_filter_start_filter_form", for example, you can add below codes into your theme/functions.php:

add_filter( 'wpv_filter_start_filter_form', 'add_class_to_form_func', 99, 4 );
function add_class_to_form_func( $out, $view_settings, $view_id, $is_required ) {
    if ( $view_id == 123) { // if it is the specific View
		$my_custom_class_name = "my-css-name"; // here setup your custom CSS class names
        $out = str_replace('js-wpv-filter-form ', 'js-wpv-filter-form ' . $my_custom_class_name . ' ', $out);
    }
    return $out;
}

Please replace 123 with your view's ID,
replace my-css-name with your custom CSS class name

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_start_filter_form
Filters the output generated by the [wpv-filter-start] shortcode.