Show all sub categories in filter sidebar by default

Actually, I didn’t use sub categories. All categories are on the same logical level, but the (pseudo) sub categories are indented by 30 px or so from the left. So I get a tree like look. My main aim was to have the full tree expanded at any time, no matter what. The default behaviour of hivepress is to only show the current category and hide all others. For my purpose this wasn’t the right thing. Therefore I hardcoded all categories in the filter “hivepress/v1/forms/listing_filter”.

The pseudo “sub” categories are targeted by CSS to achieve the indent (margin-left). This is also the reason for the “attributes” array in the code above. This adds the class “filter_categories” to the output which can then be targeted by CSS. It’s not a very elegant solution but it works for me. I only have a few categories and they are pretty permanent, therefore this hardcoded solution is good enough for my purpose.

Here’s a screenshot of the categories filter:

2 Likes