function theme_slug_filter_the_content( $content ) {
$content = preg_replace_callback(
'/<a\s+href="([^"]+)"[^>]*>([^<]+)<\/a>/i',
function($matches) {
if ($matches[1] === $matches[2]) {
return '<span class="link_fix" href="'.$matches[2].'">' . $matches[2] . '</span>';
} else {
return $matches[0]; // Return unchanged anchor tag
}
},
$content
);
return $content;
}
add_filter( 'the_content', 'theme_slug_filter_the_content', 999999);
Jagdish Sarma Asked question March 14, 2024