• Serge

    (@sergevinokour)


    Is it possible to define menu option visibility / accessibility based on url? The goal is to have different options (sub-menus), depending on permalink mask. E.g. Categories on /category/* pages, but not on others.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi Serge,

    There’s nothing built in to let you do that, but you could do it with custom CSS. If you look at the <body> tag, you should be able to pick out a class that is unique to that page/category. E.g. “page-id-123”. Then you can use CSS to hide/show items based on that class. E.g.

    /* Hide menu item 456 on page 123 */
    body.page-id-123 #menu-item-456 {
       display: none !important;
    }

    Regards,
    Tom

    Thread Starter Serge

    (@sergevinokour)

    Hi Tom, thank you for reply. Yes I understand the CSS option. Although the problem is that our business team wants to manage menu and make “dynamic” visibility for the selected options and related sub-trees. It could be achieved with CSS if there were an option to add custom classes to the options, e.g. all options to be hidden on certain page to have “not-to-show-on-page-A” class (added through admin interface) and related CSS as you suggested.
    Ideally, such links should not be generated at all, same as “hide on mobile” or registered-user-only.
    I hope this feature can be deployed with future relases.
    Thank you,
    Serge

    Plugin Author megamenu

    (@megamenu)

    Hi Serge,

    I understand. You could add a custom CSS class to a group of menu items to make it a bit easier:

    /* Hide all items with 'hide-on-123' class on page 123 */
    body.page-id-123 .hide-on-123 {
       display: none !important;
    }

    I agree it’s not perfect, but it’s the only way I can think to do it (other than PHP which would be more complicated). I’ll certainly make a note of your suggestion.

    Regards,
    Tom

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Page-dependent Visibility’ is closed to new replies.