• + Admin creates a bunch of navigation menus via the appearance > menu admin screen.
    + These menus are not assigned to specific theme_locations. There could be dozens of these admin-created menus.
    + My single.php or single-customposttype.php would display the correct nav menu based on whether that nav menu contains the currently-viewed page.

    Ie: If nav menu contains a page with page id of this current page’s $post_ID, then return the nav menu.

    Should I assume that I would use a custom walker that is passed the current page’s ID as an argument?

    Then on my single.php or single-customposttype.php I’d use the wp_nav_menu() function with a “walker” argument pointing to this new walker object?

    If so, any thoughts on modifying a walker that would do this?

    Thank you!

Viewing 1 replies (of 1 total)
  • Thread Starter skinnytires

    (@skinnytires)

    For anyone who cares:

    + Use wp_nav_menu($args) like normal but with a custom walker
    + Within your custom walker, get the link’s target page’s id via $item->object_id and you should be good from there.

    Next up is to see if I can modify the admin menu page with any ease…

Viewing 1 replies (of 1 total)
  • The topic ‘Display correct menu based on if it contains current page’ is closed to new replies.