How do WordPress commenter links open in a new window?Comment external links automatically transfer to internal link codes

WordpressHow does the commenter link open and jump in a new window?

Comment external links automatically transfer to internal link codes

If you don’t want some people to intentionally fill in the URL of the blocked website in the commenter’s link, because such a link has the risk of being blocked.

Therefore, this article continues to share:WordPress commenter external links are automatically converted into internal link codes

Step 1: Automatically convert the external link of the article into the internal link code

Please complete this tutorial firstHow does WordPress convert external links to internal links?The external link of the article is automatically converted into the internal link code", before continuing to operate this tutorial.

Step 2: Add Commenter Link Jump Code

Add the following code to the function.php file of your WordPress theme.

2-to-1 code:

  • 1) [Recommended] The commenter link jumps and opens the code in a new window (base64 encryption)
  • 2) The commenter link jumps and opens the code in a new window (no encryption)

1) [Recommended] The commenter's link jumps and the new window opens the code (base64 encryption):

// 评论者链接跳转并新窗口打开(base64加密)
 function commentauthor($comment_ID = 0) {
 $url = get_comment_author_url( $comment_ID );
 $author = get_comment_author( $comment_ID );
 if ( empty( $url ) || 'http://' == $url )
 echo $author;
 else
 echo "<a href='go.html?url=".base64_encode($url)."' rel='external nofollow' target='_blank' class='url'>$author</a>";
 }

2) The commenter link jumps and opens the code in a new window (no encryption):

// 评论者链接跳转并新窗口打开(无加密)
 function commentauthor($comment_ID = 0) {
 $url = get_comment_author_url( $comment_ID );
 $author = get_comment_author( $comment_ID );
 if ( empty( $url ) || 'http://' == $url )
 echo $author;
 else
 echo "<a href='go.html?url=$url' rel='external nofollow' target='_blank' class='url'>$author</a>";

If you want the reviewer's jump link to be able to display the URL, you can choose no encryption code.

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top