This works in a widget at least testing with the coming 3.0
<?php
//list terms in a given taxonomy (useful as a widget for twentyten)
$taxonomy = 'genre';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
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>';
}
?>
</ul>
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).
<?php
//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
);
?>
<ul>
<?php
wp_list_categories($args);
?>
</ul>
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:
http://test.com/blog/category/
Links should be like this, e.g.:
http://test.com/blog/type/chair/
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?