0

I have a list of custom taxonomy and wish to add the number of posts in brackets, (9), after each listing.

<?php
$taxonomy = 'judges';
$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 shows for %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a> </li>';
}
?>
</ul>

I am using code shown on this thread Custom Post Type Category List & Post Count and see that I should use $tax_term->count

Unfortunately, I don't have a clue how to use this. I have tried inserting it into the code in different ways and places but I am obviously total ignorant!

Can anybody please advise me exactly where I place this and how to show the count in brackets?

Thanks in advance!

1
<?php
$taxonomy = 'judges';
$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 shows for %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name . '(' . $tax_term->count . ')</a> </li>';
}
?>
</ul>

Try that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.