效果演示

怎么样?跳转页面还是挺好看的吧!

第一步,建GO文件夹

首先在网站根目录创建一个名字为 go 的文件夹,并在该文件夹中放入含有GO跳转的 index.php。

index.php文件已经准备好了:https://sn9.us/file/22696366-414441330

第二步,编辑functions.php

将下列代码放入functions.php文件底部,大功告成!

function the_content_nofollow($content){
preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches);
if($matches){
foreach($matches[2] as $val){
if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){
$content=str_replace("href=\"$val\"", "href=\"".home_url()."/go/?url=$val\" ",$content);
}
}
}
return $content;
}
add_filter('the_content','the_content_nofollow',999);