Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

You could achieve this with a custom walker function, on your menu. a very simple example:

class Walker_WPA82563_Submenu extends Walker_Nav_Menu {
    function end_el(&$output, $item, $depth=0, $args=array()) {
        if( 'Boats' == $item->title ){
            $output .= '<ul><li>Dynamic Subnav</li></ul>';
        }
        $output .= "</li>\n";  
    }
}

Then where you call the nav menu, create an instance of your custom walker with the walker argument.

wp_nav_menu(
    array(
        'theme_location' => 'primary',
        'walker' => new Walker_WPA82563_Submenu
    )
);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.