Support » Fixing WordPress » How to avoid duplicated tags on index.php ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Why not just show random (post) tags? Something like this:

    // display 5 random tags
    $tags = get_terms('post_tag');
    if($tags) {
      $out = '';
      $rand_keys = array_rand($tags, 5);
      foreach ($rand_keys as $key) {
        $out .= '<a href="' . get_term_link( $tags[$key], 'post_tag' ) . '"';
        $out .= ' title="' . esc_attr(sprintf( __( "View all posts in %s" ), $tags[$key]->name )) . '">';
        $out .= '<span>'. $tags[$key]->name.'</span></a><br/>';
      }
      echo $out;
    }

    modeman

    (@modeman)

    Thanks, worked nice 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to avoid duplicated tags on index.php ?’ is closed to new replies.