Sub-Pages only of menu items in current branch using a custom menu

Although I did a thorough research I could not find a solution. Only solutions coming close.

My custom menu (“top”) shows this structure (you see a part of it):

page 1
  subpage 1.1
    category A
    subsubpage 1.1.1
    subsubpage 1.1.2
  subpage 1.2
    category B
    subsubpage 1.2.1
    subsubpage 1.2.2
  subpage 1.3
    category C
    subsubpage 1.3.1
    subsubpage 1.3.2
page 2
page 3

Without using CSS (the real structure is by far bigger) I would like to display this in the sidebar, when a user currently looks at page 1 (only its children items):

  subpage 1.1
  subpage 1.2
  subpage 1.3

And when the user currently looks at subpage 1.1 or any of its custom menu children (incl. posts in category A):

  subpage 1.1
    category A
    subpage 1.1.1
    subpage 1.1.2
  subpage 1.2
  subpage 1.3

To put it in words:

Visible menu items:

  • menu items on level 2 (if there are any)
  • children of level 2 menu items only for items in the current branch (current-menu-ancestor, current-menu-parent, current-menu-item)

I tried a few Custom Walker classes presented in that forum, none of them did the trick.

I also tried the plugin Advanced Menu Widget (, which comes very (!) close, but there seems to be a bug in it. Use of these settings would do the job generally:

  • Show hierarchy: Only related sub-items
  • Starting depth: 1

Unfortunately it does not provide the result looking at category A or it’s posts in my example.

Thank you in advance.

Solutions Collecting From Web of "Sub-Pages only of menu items in current branch using a custom menu"

Using the plugin “Advanced menu widget” by Ján Bočínec one can get pretty close. With one big exception: when you look at a post from category A, the whole sub-menu vanishes (except for a remaining empty <ul></ul>-construct).

So we are still looking for a working solution. We are going to try it now with Gecka submenu plugin and tons of CSS. But I am afraid that even this plugin does not provide enough CSS classes.

Thus this is half an answer 😉