This functionality will be very useful for those users who have long parent-sub category list on his/her site. WordPress have default Categories widget. I am adding the toggle effect there and hiding the all sub categories. Clicking on the “+” icon respective sub categories will expend. Just following the bottom steps and achieve this functionality.
Assuming that you already added the “Categories” widget at your sidebar.
Step 2:
We need to enqueue this js file for front end only. Open the functions.php file and add the following the PHP script there:
Step 3:
This is the last step. Doing some fancy design for professional look. You will change this CSS codes as per your site design. Here is my CSS (style.css file):
If you need any help then you can feel free ask me.
Leave A Reply