你是我的英雄。我通过与您的代码的内部链接解决了我的问题。我不得不修改它,因为在我的代码rel=“nofollower noopener”和rel=“noopener nofollower”中有许多不同的rel,所以我修改了以下内容:
add_filter( \'the_content\', \'ex1_the_content_filter\' );
function ex1_the_content_filter($content) {
// finds all links in your content with a nofollow
preg_match_all(\'/\\<a .*?nofollow.*?a>/\',$content,$matches, PREG_SET_ORDER);
// loop through all matches
foreach($matches as $m){
// potential link to be replaced...
$toReplace = $m[0];
// You can add whatever additional "IF" conditions you require to this one
if (preg_match(\'/.*?\\/link.*?/\',$toReplace)){
// removes rel="nofollow" from the current link
$replacement = preg_replace(\'/(<a.*?)(nofollow )(.*?a\\>)/\',\'$1$3\',$toReplace);
// replaces the current link with the $replacement string
$content = str_ireplace($toReplace,$replacement,$content);
}
}
return $content;
}