• Resolved g10r3

    (@g10r3)


    Hi,

    i’m trying to get a list of the terms from a custom taxonomy with the numer of post associated with.

    I’ve tried

    wp_tag_cloud( array( 'taxonomy' => 'tema', 'number' => 0, 'format' => 'list' ) );

    and it generate the list, with also the links, but it seems that there’s no way to add the post count.

    After some search i’ve found a metod to generate a tag list with post count

    $tags = get_tags(array(
    			'orderby' => 'name',
    			'order' => 'ASC',
    			'number' => 0,
    			) );
    
    			foreach ($tags as $tag) {
    			echo '<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . '</a> (' . $tag->count . ')<br />';
    			}

    but i can’t find a way to adapt the code and get the list of the terms of my custom taxonomy.

    Can you help me?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter g10r3

    (@g10r3)

    Something like this?

    $terms = get_terms('tema', 'orderby=name&order=ASC&number=0');
    
    foreach ($terms as $term) {
    		echo '<a href="' . get_term_link($term->termID) . '">' . $term->name . '</a> (' . $term->count . ')<br />';
    }

    It doesn’t seem to work….

    Thread Starter g10r3

    (@g10r3)

    ok, now it works!

    $myterms = get_terms('tema', 'orderby=name&order=ASC&number=0');
    
    		foreach ($myterms as $singleterm) {
    		echo '<a href="' . get_term_link($singleterm, $singleterm->taxonomy ) . '">' . $singleterm->name . '</a> (' . $singleterm->count . ')<br />';
    		}

    Thank u for the hint.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘list of custom taxonomies and number of related post’ is closed to new replies.