[英]I want to remove the “nofollow” attribute from all internal links on my WordPress site
有很多插件可以做相反的事情,并且只用于外部链接。
我正在尝试找到一种方法来轻松删除仅适用于我网站(WordPress)上所有内部链接的 nofollow 属性。
我不关心 rest。
想法?
下面的代码片段将检查页面内容和评论字段,以便查看字符串是否包含站点 url,如果设置为 true,则删除任何 no-follow 属性(如果设置)。 这是假设链接使用的是绝对路径。
function remove_nofollow($string) {
$internal = get_site_url();
if ( str_contains( $internal, $string ) {
$string = str_ireplace(' rel="nofollow"', '', $string);
}
return $string;
}
add_filter('the_content', 'remove_nofollow');
add_filter('comment_text', 'remove_nofollow');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.