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 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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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;
}
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.