Title: Display tags only if assigned to more than one post
Last modified: August 19, 2016

---

# Display tags only if assigned to more than one post

 *  Resolved [csleh](https://wordpress.org/support/users/csleh/)
 * (@csleh)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/using-the_tag/)
 * is there a way to limit this:
 * `<?php the_tags(); ?>`
 * to only show if there are other posts with the same tag?

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/using-the_tag/#post-1020756)
 * > to only show if there are other posts with the same tag
 *     ```
       <?php
       $tags = wp_get_post_tags($post->ID);
         if ($tags) {
           foreach($tags as $tag) {
             if ($tag->count > 1) {
               echo '' . $title . '<a href="' . get_term_link( $tag->term_id, 'post_tag' ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> is assigned to ' . $tag->count . ' posts.
        ';
             }
           }
         }
       ?>
       ```
   
 *  Thread Starter [csleh](https://wordpress.org/support/users/csleh/)
 * (@csleh)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/using-the_tag/#post-1020804)
 * Thank you!! Works perfectly
 *  [afsender](https://wordpress.org/support/users/afsender/)
 * (@afsender)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/using-the_tag/#post-1020964)
 * Great! But where to put the code?
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/using-the_tag/#post-1020965)
 * First review [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy)…
   your theme’s index.php or archive.php or category.php are possibilities.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Display tags only if assigned to more than one post’ is closed to new
replies.

## Tags

 * [limit](https://wordpress.org/support/topic-tag/limit/)
 * [meh_code](https://wordpress.org/support/topic-tag/meh_code/)
 * [the_tag](https://wordpress.org/support/topic-tag/the_tag/)

 * 4 replies
 * 3 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/using-the_tag/#post-1020965)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
