menus - Change submenu markup

admin2025-01-07  4

I've seen people recommending to edit the wordpress default Walker to change the menu markup and create your own.

The problem with this is that I would like to change the markup of the submenu and leave the menu as it is.

In the walker function I only saw the functions start_lvl and end_lvl regarding the submenu creation. The functions itself lack of very useful comments... so I understood that lvl means "level" and with that they mean "sub-menu"...

But it doesn't seem to be any specific function to render the submenus. It seems they use the same one for the parent menu than for the submenu.

Any recommendation? I would like to create a menu like this and I'm having troubles.

I've seen people recommending to edit the wordpress default Walker to change the menu markup and create your own.

The problem with this is that I would like to change the markup of the submenu and leave the menu as it is.

In the walker function I only saw the functions start_lvl and end_lvl regarding the submenu creation. The functions itself lack of very useful comments... so I understood that lvl means "level" and with that they mean "sub-menu"...

But it doesn't seem to be any specific function to render the submenus. It seems they use the same one for the parent menu than for the submenu.

Any recommendation? I would like to create a menu like this and I'm having troubles.

Share Improve this question asked Oct 3, 2015 at 19:06 AlvaroAlvaro 1411 silver badge12 bronze badges 1
  • 1 I think this requires a lot of customization. Anyway, I too look for a solution to this specific use case. – Hareesh Sivasubramanian Commented Oct 3, 2015 at 19:13
Add a comment  | 

1 Answer 1

Reset to default 0

The whole idea of a custom walker class is that you can customize the menu in detail. So, you can also leave the main menu as it is and build the submenus the way you give in the image.

However, as Hareesh indicates in the comments, this does require quite a lot of customization, especially if you want you theme to be widely applicable (meaning you'll have to take into account errors, such as missing images in the submenu). This might be a nice place to start understanding the walker class.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736264640a983.html

最新回复(0)