Site logo

Archived topic

Open URL from Comment Form in external Window

3 replies · Started by Nathanael on March 14, 2018

Viewing posts 1–4 of 4

Hello,

can you give me a php snippet, that the urls from the comment (provided in the url field) section open in a new window (with target="_blank")?

Thank you,
Nathanael

Hi there,

You could try this:

add_filter( 'get_comment_author_link', 'tu_open_comment_author_link_in_new_window' );
function tu_open_comment_author_link_in_new_window( $author_link ) {
    return str_replace( "<a", "<a target='_blank'", $author_link );
}

Hi Tom,

works perfectly. Thank you!

You're welcome :)

This archived topic is closed to new replies.