By default, the first 5 filters are always expanded, while subsequent filters are collapsed. This behavior can be adjusted in the plugin settings under WooCommerce -> FiboFilters -> Appearance -> Allow collapsing filters
.
The option applies to all views, including desktop, mobile, and off-canvas. However, you can set a different value for each of these views, which requires using a PHP snippet as demonstrated below.
Setting collapsing values for different views
When the “Allow collapsing filters” option is enabled, all three keys (collapse_after
, off_canvas_collapse_after
, mobile_collapse_after
) are set to 5
by default. This means that filters will collapse after the fifth element in all views.
Here’s an example of how to use the filter to customize collapsing behavior across different views:
add_filter( 'fibofilters/filters/collapsing', function ( $collapsing ) { $collapsing['collapse_after'] = 3; // Collapse after the third filter $collapsing['off_canvas_collapse_after'] = 0; // Collapse all filtersin the off-canvas view. $collapsing['mobile_collapse_after'] = -1; // Do not collapse any elements in the mobile view. return $collapsing; } );
Explanation of specific values
- Value
> 0
– Filters collapse after then
element. - Value
0
– This value collapses all filters in the corresponding view. - Value
-1
– This value disables collapsing entirely, ensuring that all filters remain fully expanded in the view.