WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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.