get_the_term_list() – output number of terms associated with current post
I’ve just started using custom post types and I can’t figure aout how to display the number of termes my cpt is associated with for a given taxonomy.
I have a custom post type named “cars”
I have two taxonomies named “brands” and “options”
In options, I have all possible options “sun-roof”, “stick-shift”, “four-wheel drive”…
I would like to be able to output the number of options a car has (kind of the same way we would display a comment count).
>> Options : (9)
The reason why I would like to do this, is that on archive pages rendering the entire list of options for each vehicle kind of messy. So i’d like to be able to give people an indication of how well equipped each vehicle is.
I am currently using
<?php echo get_the_term_list( $post->ID, 'options', '', ', ', '</p>' ) ?>
Any help would be great,
- The topic ‘get_the_term_list() – output number of terms associated with current post’ is closed to new replies.