1

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
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.

1
  • It seems a dirty solution for now. The branches might change so I need an automated solution. There is also a second part, which will take each li from .last and show them into another div (like a detached ul:last-child menu), but I'd like to create the menu using plain menu editor. I will try some more else in a couple of days I'll mark your answer. – Panagiotis Nov 1 '12 at 18:13

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.