Starting with Link Whisper 2.3.5, in-content link URLs can be modified to suit your site’s needs by using pre-display filters.
Doing this requires the use of two filters. The first is ‘wpil_add_link_attr_allow_change_url’, and it’s job is to tell Link Whisper that you want to modify link URLs.
The second filter is ‘wpil_add_link_attr_change_url’, and it’s job is to do the actual modifying.
As an example, here is a code snippet that makes sure all internal links have a trailing slash:
// This tells Link Whisper that we want to adjust the URLs in links
add_filter('wpil_add_link_attr_allow_change_url', function(){ return true; });
// This is the code that will add trailling slashes to all internal links
add_filter('wpil_add_link_attr_change_url', 'link_whisper_add_trailing_slashes', 10, 2);
function link_whisper_add_trailing_slashes($url = '', $is_internal = false){
// if the link is internal
if($is_internal){
// make sure it has a trailing slash
$url = trailingslashit($url);
}
// make sure to return the URL
return $url;
}
To install code such as this, you will need to insert it in your child theme’s functions.php file. If that’s not possible, or you’re not using a child theme, then the next best way to do it is with a PHP Code Snippets plugin.