• Resolved csleh

    (@csleh)


    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)
  • 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

    (@csleh)

    Thank you!! Works perfectly

    afsender

    (@afsender)

    Great! But where to put the code?

    MichaelH

    (@michaelh)

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