custom walker wp menu last element

I have a menu list with many subitems that contain submenus as well (at the moment some reach 4th level).

How can I put on each last descended ul of each li element a class “.last”?
for example I have

MENU
 PASTA
  SUBITEM 1 (.last)
   ITEM 1.1
   ITEM 1.2
  SUBITEM 2 (.last)
   ITEM 2.1
   ITEM 2.2
 PIZZA
  SUBITEM 3
   SUBITEM 3.1 (.last)
    ITEM 3.1.1
    ITEM 3.1.2
 DESSERTS
  SUBITEM 4
   SUBITEM 4.1
    SUBITEM 4.1.1 (.last)
     ITEM 4.1.1.1
     ITEM 4.1.1.2
  SUBITEM 5 (.last)
   ITEM 5.1
   ITEM 5.2

Related posts

Leave a Reply

1 comment

  1. If you can live without re-creating the menu walker, you can add classes to menu items manually.

    On the WordPress menu editing screen, click on “Screen Options” and enable “CSS Classes.” Then you’ll be able to add whatever class you want to whichever list item.

    Creating a custom Walker for something like this will be complicated, to say the least.