Description
This filter allows you to add CSS classes to the .wpsl-search div of the [wpsl] template. This is the div that holds the search form, inside the outer #wpsl-wrap div.
So if you have multiple store locator pages, then you could use this to apply different styles without having to create a different template.
#wpsl-wrap div, which works with every template, use the wpsl_template_outer_classes filter. See the second example below.Parameters
$classes - (array) The CSS classes. Depending on your settings, the array can already hold classes like wpsl-cat-results-filter, wpsl-no-filters, wpsl-checkboxes-enabled, wpsl-results-only and wpsl-cat-filter-only.
Usage
The code below shows how to set a ‘wpsl-custom-css’ class on the search form of the page with the ‘your-page-slug’ permalink.
| add_filter( 'wpsl_template_css_classes', 'custom_template_css_classes' ); | |
| function custom_template_css_classes( $classes ) { | |
| // Only add the class on the page with the 'your-page-slug' permalink. | |
| if ( is_page( 'your-page-slug' ) ) { | |
| $classes[] = 'wpsl-custom-css'; | |
| } | |
| return $classes; | |
| } |
This example adds the same class to the outer #wpsl-wrap div instead, with the wpsl_template_outer_classes filter. It works with the Default, Horizontal and Vertical templates, and with custom templates.
| add_filter( 'wpsl_template_outer_classes', 'custom_template_outer_classes' ); | |
| function custom_template_outer_classes( $classes ) { | |
| // Only add the class on the page with the 'your-page-slug' permalink. | |
| if ( is_page( 'your-page-slug' ) ) { | |
| $classes[] = 'wpsl-custom-css'; | |
| } | |
| return $classes; | |
| } |
You can then scope your CSS to that page, for example #wpsl-wrap.wpsl-custom-css or .wpsl-search.wpsl-custom-css.
Changelog
| Version | Description |
|---|---|
| 3.0 | Moved to includes/frontend/assets/class-manager.php. Only used by the Default and Horizontal templates. The new wpsl_template_outer_classes filter sets the classes on the outer #wpsl-wrap div. |
| 2.1.0 | Introduced. |
Source File
This filter is located in /includes/frontend/assets/class-manager.php.
Placement
The code needs to be placed in the functions.php file inside your active theme folder.