okp
okp

Reputation: 13

Wordpress menu: automatically add categories

In Wordpress, i'd like to automatically add categories from custom post types in a submenu item, with respecting the hierarchy.

This is how my menu will look like:

Any idea on how to automatically add all categories in the menu, under "Categories" item? (It's a menu created in Appearance > Menus) I guess i might use wp_list_categories() but I have no idea where to place this...

Thanks !

Upvotes: 1

Views: 3040

Answers (1)

Vaino
Vaino

Reputation: 33

Try this filter

It's a little hacky but i managed to add some stuff into my menus from here

WP nav menu itmes

function wp_nav_menu_items( $items, $args ) {
    if ( "primary" == $args->theme_location ) { //check what menu it is
        //Do Stuff here
    }

    return $itmes;
}

add_filter( wp_nav_menu_items, wp_nav_menu_items );

Upvotes: 1

Related Questions