1. Go to Stores > Attributes > Products & Click on Create new or edit an already created attribute.

2. If you select the use in layered navigation option to be yes you will see an extra option
Use for specific categories in Front-end Tab (Bottom Section)

3. If you want to use your attribute for all the categories you can select no and the attribute
will be visible in all the categories
4. If Attribute is required in an only a specific category, you can select yes and you will see a
multi-select box with a list of categories created.

5. You can select all the categories in which you want your attribute to be displayed and
the attribute will be visible only in those specific categories.

● Note: The filter will not work with root Category so please never select it in
multi select box.
● Filters will only work if Module is enabled from system Configuration