Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can anyone tell me how I can show a post count in this code snippet?

<?php $tags = get_tags();
   if ($tags) {
   foreach ($tags as $tag) {
   echo '<li><a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> </li> ';
   }
};?>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

where exactly? example below is for the count getting shown in brackets after the tag name, outside the link:

<?php 
$tags = get_tags();    
  if ($tags) {    
  foreach ($tags as $tag) {    
    echo '<li><a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> ('.$tag->count.') </li> ';    
  } 
  };
?> 

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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