WordPress recently added the feature of highlighting text and pasting a URL onto it to create a link. It’s fast and easy, but you have to go into Link Options¬†of that link and click Open link in a new tab. Visit this site to see the example. What a pain when you’re working on a chart or index that has hundreds of links.

Here’s an easy way; add this code to your functions.php file, just above the ?> ending. Basically it’s automatically adding target=”_blank” to any link that’s not your own URL. Replace yoursiteURL below.

function autoblank($text) {
$return = str_replace(‘href=’, ‘target=”_blank” href=’, $text);
$return = str_replace(‘target=”_blank” href=”http://www.yoursiteURL.com‘, ‘href=”http://yoursiteURL.com‘, $return);
$return = str_replace(‘target=”_blank” href=”#’, ‘href=”#’, $return);
$return = str_replace(‘ target = “_blank”>’, ‘>’, $return);
return $return;
}

I suggest doing this in a child theme, which is a whole other topic.