Support » Fixing WordPress » List categories for custom post type

  • Resolved DennisvanHouts


    I registered a custom post type (called product) with a custom taxonomy (calles type, it’s hierarchical). Now I want to display all those product types in a list, just as you would display the post categories.

    I’m trying something like this:
    wp_list_categories(array(‘taxonomy’ => ‘type’));

    This shows exactly what I want, a list of all those types with also the subtypes. Only problem is that the links don’t show up right. They point to the post category page (

    Anyone any ideas to make a list for the custom taxonomy?

Viewing 6 replies - 1 through 6 (of 6 total)
  • This works in a widget at least testing with the coming 3.0

    //list terms in a given taxonomy (useful as a widget for twentyten)
    $taxonomy = 'genre';
    $tax_terms = get_terms($taxonomy);
    foreach ($tax_terms as $tax_term) {
    echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';

    It does work.

    Only thing: now all the taxonomies are nicely listed, but because the taxonomy is hierarchical I want to show the subtaxonomies onder their parent.

    When listing categories for posts, the child is listed under the parent automaticly, can this be also be done for taxonomies?

    Didn’t realize you could do this, but you will like it! Beware the ‘taxonomy’ argument with wp_list_categories is only available in the coming 3.0 (or the 3.0 beta if you are using that).

    //list terms in a given taxonomy using wp_list_categories  (also useful as a widget)
    $orderby = 'name';
    $show_count = 0; // 1 for yes, 0 for no
    $pad_counts = 0; // 1 for yes, 0 for no
    $hierarchical = 1; // 1 for yes, 0 for no
    $taxonomy = 'genre';
    $title = '';
    $args = array(
      'orderby' => $orderby,
      'show_count' => $show_count,
      'pad_counts' => $pad_counts,
      'hierarchical' => $hierarchical,
      'taxonomy' => $taxonomy,
      'title_li' => $title

    Yes, I’m using the 3.0 beta. Using your code it shows the taxonomies and subtaxonomies the way I want it, but the links it generates aren’t correct.

    All the links point to the category page.

    Like this:

    Links should be like this, e.g.:

    No, sorry, I take it back. I was using the alpha release in which it didn’t work. It does work in the beta release. Thanks, this helps alot!



    Hi, im using the beta release and im not able to display custom taxonomies. I have used the code above and nothing. Also the custom taxonomies are not showing up in the new menu editor, will that be available on the oficial release?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List categories for custom post type’ is closed to new replies.