• Is it possible to show the count beside each taxonomy term? I’ve been trying hard to modify the plugin code to show the count, and even use the get_the_term_list function directly, but I can’t figure it out. I’m wondering if it might not be possible to show the term count as long as we’re using the get_the_term_list and get_term function? If this is the case, then this would stop another search of mine, from a previous forum post, where I’m looking to restrict the terms to those with a count > 1.

    Is this the case, does anyone know?

    http://wordpress.org/extend/plugins/taxonomy-terms-list/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Michael Fields

    (@mfields)

    I don’t believe that get_the_term_list() allows you to display count.

    Heres one way of doing it:

    $term = get_term_by( 'slug', 'term_slug', 'taxonomy_slug' );
    print $term->count;

    Basically, anytime you have a term object at your disposal, you can use the count property.

    Something important to mention: Currently, it is not really a good idea to rely on term->count to determine whether or not you should display posts. I have received reports from users of my Taxonomy List Shortcode that the terms will display with a count of one even if there are no published post associated with the term… if the post is a draft.

    Here are a few trac tickets that seem to report the same type of issue:

    http://core.trac.wordpress.org/ticket/14392
    http://core.trac.wordpress.org/ticket/14084
    http://core.trac.wordpress.org/ticket/14073

    Thread Starter iftomkins

    (@iftomkins)

    Very good to know. I can’t seem to figure out how to get the terms only for that particular post (replicating the Terms List Plugin but in the page template). Is this something that can be done? Honestly, I was hoping to cut and paste something into your plugin code that would let me show the count. But I’m thinking I would have to replicate the plugin actions, but for get_terms_by instead of get_the_term_list?

    Plugin Author Michael Fields

    (@mfields)

    You might want to try get_object_terms().

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Taxonomy Terms List] Show Count possible with get_the_term_list?’ is closed to new replies.