2

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 (http://wordpress.org/extend/plugins/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.

4
  • Had you looked at Display a portion/ branch of the menu tree using wp_nav_menu()? There are multiple answers and approaches to displaying menu branches there.
    – Rarst
    Mar 17, 2012 at 20:44
  • Thank you, Rarst. Yes, I looked there and tried all of them. But did not get the desired result. BTW, jessegarvins problem can easily be solved by using the Gecka submenu plugin (wordpress.org/extend/plugins/gecka-submenu). Unfortunately I can't comment there due to lack of reputation points.
    – hedu
    Mar 18, 2012 at 13:47
  • We solved it by using the plugin "Advanced menu widget" (which works perfectly), but we had to change some names. The source of the problem was, that we also use 'The events calendar', and we named an events category the same way as we named a Wordpress category for posts before. This confuses the Walker, and the plugin has noch chance for the right output. Solution: never use the same name (label) for categories or other taxonomies even if they stem from different sources.
    – hedu
    Mar 21, 2012 at 8:03
  • Please add your solution as an answer, that is more in line with site's mechanics and this question won't haunt site as unanswered.
    – Rarst
    Mar 21, 2012 at 11:24

1 Answer 1

2

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 ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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