[Resolved] Open URL from Comment Form in external Window

Home Forums Support [Resolved] Open URL from Comment Form in external Window

Home Forums Support Open URL from Comment Form in external Window

  • This topic has 3 replies, 2 voices, and was last updated 6 years ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #520346
    Nathanael

    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

    #520852
    Tom
    Lead Developer
    Lead Developer

    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 );
    }
    #521202
    Nathanael

    Hi Tom,

    works perfectly. Thank you!

    #521300
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.