• I’m building a site with a main menu in the header and a sidebar menu on the inside pages. I’m using wp_nav_menu to pull in both. I have the main menu that has “about, services, who we are etc. For example, services has 3 sub items. When user lands on any of the sub pages I would like for the sidebar menu to only show the sub items for that parent menu item. So menu on side would look like this…

    SERVICES

    – sub item
    – sub item
    – sub item

    On who we are page:

    WHO WE ARE

    – sub item
    – sub item

    I would think this is possible and also to have the services title at top of menu be dynamically brought in.

    Are there args that I can use in the wp nav menu function to handle this?

    Thank you for any help and hopefully I was clear enough to what I’m seeking.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can use the widget from this plugin: CC Child Pages

    • This reply was modified 3 years, 9 months ago by Joy. Reason: forgot link text
    Thread Starter tkmets5

    (@tkmets5)

    Thanks I’ll take a look. I’m not using a registered sidebar however. I just have a hard coded sidebar. I don’t need any widgets. I’m surprised there isn’t a way within WP to add args to make this work.

    Moderator bcworkz

    (@bcworkz)

    Not via args. You can use ‘wp_nav_menu_objects’ filter to unset undesired menu item objects. The “current” property can be used to identify which item is for the current page. Then use the “post_parent” property to determine sibling and ancestor items. The trick will be in distinguishing the main menu call where you want all items, from the sidebar call where you don’t. Adding the filter from your sidebar code after the main menu is output could work, assuming there is not a subsequent footer menu.

    Consider what to do if no item has the “current” property set as true.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Wp nav menu customization’ is closed to new replies.