How to output all taxonomy links from a custom post type in a menu?

I made a custom post type called Product. And a taxonomy with the name ‘product-category’. These taxonomies have pages where we show a list of the products that have that taxonomy.

Now my question is how to get all the taxonomies as a menu in the header. Its an awful lot of work to add it manually in the menu editor. Also because i need sub-menu’s and sub sub menu’s. How do I do this?

Solutions Collecting From Web of "How to output all taxonomy links from a custom post type in a menu?"

You can use wp_list_categories() which by default, generates nested unordered lists (ul) and just pass product-category as the taxonomy parameter for example:

add_filter('wp_nav_menu_items','add_custom categories', 10, 2);
function add_custom categories($items, $args) {

    $items .= '<li>' . wp_list_categories( array('echo' => 0, 'taxonomy' => 'product-category', 'title_li' => 'Product Categories') ) . '</li>';
    return $items;
}