Plugin Author
wizzud
(@wizzud)
Under the Fallbacks section, try setting…
“If no Current Item can be found” (checkbox)
This gets applied right at the start of processing, when determining which of the menu items (if any) should be regarded as the unique “Current Item” by this widget. Under certain conditions, WordPress will mark an item as being the parent of a current item … but there won’t actually be a current item marked! This occurs, for example, when displaying a full post for which there is no specific related menu item, yet there is a menu item for a Category that the displayed post belongs to : WordPress will then mark the related Category as being the parent of the current item (the post) even though it can’t mark the post as being the current item (because there’s no specific item for it within the menu).
Enabling this fallback will make the widget look for these situations – only as a last resort! – and set (one of) the found “parent” item(s) as the Current Item.
Thread Starter
l r
(@lainyrache)
Thank you Wizzud!
That works!
My only slight issue is that if the post is in more than one category, the menu can switch to another sub-menu that has the other category in it – I presume that’s unavoidable?
Plugin Author
wizzud
(@wizzud)
Sorry, but currently, Yes, it’s unavoidable.
CMW can only cope with one “current item”. At present, it will use the first qualifying item it finds within the menu (it’s actually a bit more complex than that, but essentially it works on a first-found basis). This means that when the menu has category-type items – such as yours – it is quite possible for more than one menu item to marked (by WordPress) as being a possible parent candidate for a particular post. This is perfectly correct : the post does belong to each of those categories.
For example, given…
Menu Item A (lists category A items)
Menu Item B (lists category B items)
Menu Item C (lists category C items)
…if Post X belongs to categories A, B and C, WordPress will mark all 3 menu items as a possible parent, and CMW will use Menu Item A as the “current item” (in the absence of a better-qualified candidate).
In this particular example, it wouldn’t even help if CMW were switched to work on a last-found basis instead … it would simply settle on Menu Item C, which still isn’t the one you’d actually want.