Friday, December 30, 2022
HomeWordPress Developmentnofollow - No observe hyperlink for exterior websites (all website) however exlude...

nofollow – No observe hyperlink for exterior websites (all website) however exlude any class


I’ve this code, however I would really like exclude any class, or classes

perform nofollow_for_external($content material) {
$content material = preg_replace_callback(
'/<a[^>]*href=["|']([^"|']*)["|'][^>]*>([^<]*)</a>/i',
perform($m) {
if (strpos($m[1], "phoneia.com") === false)
return '<a href="'.$m[1].'" rel="nofollow">'.$m[2].'</a>';
else
return '<a href="'.$m[1].'">'.$m[2].'</a>';
},
$content material);
return $content material;
}
add_filter('the_content', 'nofollow_for_external');
// Cease self pingback
perform disable_self_ping( &$hyperlinks ) {
 $residence = get_option( 'residence' );
 foreach ( $hyperlinks as $l => $hyperlink )
 if ( 0 === strpos( $hyperlink, $residence ) )
 unset($hyperlinks[$l]);
}
add_action( 'pre_ping', 'disable_self_ping' );

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments