Support » Fixing WordPress » the_tags links to open in new tab?

  • Resolved aestock

    (@aestock)



    Is there a way to get the_tags() to generate links that open in a new tab?

    It seems that the parameters for the function control the content around the links it generates, but not the links themselves.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This should do it:

    <?php
    $posttags = get_the_tags();
    if ( $posttags ) {
        $prefix = 'Tags: ';
        foreach( $posttags as $tag ) {
            echo $prefix . '<a href="' . get_tag_link( $tag->term_id ) . '" target="_blank">' . $tag->name . '</a>';
            $prefix = ', ';
        }
    }
    ?>

    Fantastic! Did not think to use get_the_tags in conjunction with get_tag_link.

    You, sir, are a gentleman and a scholar.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_tags links to open in new tab?’ is closed to new replies.