0

I have lot of categories and sub categories. I want to add all these in WordPress menu. But i want to add subcategories aligned properly under their parent categories without drag and drop each and every time.
Right now when i select all menus from categories these does not aligned under their parent category.Is there any automated way to do this so it will save my lot of my time?
Your help will be much appreciated.

  • Nope, but there's a great plugin that can help you. It let's you choose the option to automatically fetch sub-categories. – gdaniel Aug 18 '17 at 18:34
0

You can use this function:

the_widget( 'WP_Widget_Categories', 'dropdown=1&hierarchical=1' );

This function give you a select box and you will get all the parent categories and sub-categories. After applying this code inspect category select box, then you can manipulate your HTML code. And show your category as you wish.

If you don't want any select box, then you just remove "downdown=1&". This will give you a whole list of all categories and sub-categories. After applying this code inspect category select box, then you can manipulate your HTML code. And show your category as you wish.

Hope this will help!

  • Thank you so much for your answer. But i ll need this for wordpress menu in admin panel. So that i will not need to drag sub categories to align properly. In WordPress admin panel i can see different classes for menus alignment "menu-item-depth-0". But there is no such class to target child categories so that i can change this with some jQuery. – wplearner Aug 19 '17 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.