WordPress.org

Ready to get started?Download WordPress

Forums

Count number of times a taxonomy term has been used (3 posts)

  1. Henry
    Member
    Posted 2 years ago #

    I would like to display the number of times a specific term from a custom taxonomy has been used.

    Is this possible? Any idea how to do this?

    Thanks

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    http://codex.wordpress.org/Function_Reference/get_term

    extended from the example section:

    $term = get_term( $term_id, $taxonomy );
    $count = $term->count;
  3. Henry
    Member
    Posted 2 years ago #

    @alchymyth

    Really appreciate you pointing me in the right direction. Building on what you wrote I came up with this which works for me:

    $taxonomy = "status";
    $term_name = 'active';
    $term = get_term_by('name', $term_name, $taxonomy);
    echo $term->count;

Topic Closed

This topic has been closed to new replies.

About this Topic