I’m doing a site in WP with dynamic and static content. I’d create the menu from the admin panel. I have 5 sections (Home, about, Boats, News(blog), contact). I’d create a custom post type with new taxonomies for the boats. What I want to do now is, display every new boat model as a sub menu of boats automatically. How can I do that?
Leave a Reply
You must be logged in to post a comment.
You could achieve this with a custom walker function, on your menu. a very simple example:
Then where you call the nav menu, create an instance of your custom walker with the
walker
argument.I believe there is a much better solution suited for cases when menus are truly dynamic (such as they should change depending on user role, or if there simply are too many combinations of menu items possible which need to be decided on runtime).
WordPress’
wp_nav_menu_objects
hook comes in handiest: