WordPress sets review link redirection
First: at the end of the function template <functions. php> in the topic directory?> Add the following code to the location:
The code is as follows: |
Copy code |
// Comments link redirect // The following is the wordpress redirection redirect for setting the comment link I added. Add_filter ('Get _ comment_author_link ', 'Add _ redirect_comment_link', 5 ); Add_filter ('comment _ text', 'Add _ redirect_comment_link ', 99 ); Function add_redirect_comment_link ($ text = ''){ $ Text = str_replace ('href = "', 'href ="'. get_option ('Home ').'/? R = ', $ text ); $ Text = str_replace ("href = '", "href ='". get_option ('Home ')."/? R = ", $ text ); Return $ text; } Add_action ('init ', 'redirect _ comment_link '); Function redirect_comment_link (){ $ Redirect = $ _ GET ['R']; $ Host = $ _ SERVER ['http _ host']; If ($ redirect ){ If (strpos ($ _ SERVER ['http _ referer'], get_option ('Home '))! = False ){ Header ("Location: $ redirect # form: $ host "); Exit; } Else { Header ("Location: $ redirect # form: $ host "); Exit; } } } |
// The above is my added wordpress setting comment link redirection jump
In this way, URL redirection is basically complete. The hyperlink is opened in a new window. Open the comment-template.php file under the wp-uplodes Directory, to the get_comment_author_link () function (that is, function get_comment_author_link ($ comment_ID = 0) around 147th rows )), add the target = '_ blank' attribute to the label of the else $ return line of Row 3. Modify the attribute and upload it. Complete code:
The code is as follows: |
Copy code |
Function get_comment_author_link ($ comment_ID = 0 ){ /** @ Todo Only call these functions when they are needed. Include in if... else blocks */ $ Url = get_comment_author_url ($ comment_ID ); $ Author = get_comment_author ($ comment_ID ); If (empty ($ url) | 'http: // '= $ url) $ Return = $ author; Else $ Return = "<a href = '$ url' rel = 'external nofollow' target =' _ blank 'class = 'URL'> $ author </a> "; Return apply_filters ('Get _ comment_author_link ', $ return ); } |
Add a target = "_ blank" after nofollow in the first sentence according to the following example ".
Set the Nofollow attribute of the comment link
Add the Nofollow attribute to the wordpress comment link and set the URL jump to avoid spam comments and the impact of spam links on the quality of your blog. You can modify this code in the functions. php function file below,
The code is as follows: |
Copy code |
Add_filter ('Get _ comment_author_link ', 'Add _ redirect_comment_link', 5 ); Add_filter ('comment _ text', 'Add _ redirect_comment_link ', 99 ); Function add_redirect_comment_link ($ text = ''){ $ Text = str_replace ('href = "', 'href ="'. get_option ('Home ').'/? R = ', $ text ); $ Text = str_replace ("href = '", "href ='". get_option ('Home ')."/? R = ", $ text ); Return $ text; } Add_action ('init ', 'redirect _ comment_link '); Function redirect_comment_link (){ $ Redirect = $ _ GET ['R']; If ($ redirect ){ If (strpos ($ _ SERVER ['http _ referer'], get_option ('Home '))! = False ){ Header ("Location: $ redirect "); Exit; } Else { Header ("Location: http://www.111cn.net/"); // This link is replaced with your own website Exit; }
|
The above is how to add the Nofollow attribute to the wordpress comment link and set the redirect Redirect Method for the comment link.