Open all links in new windows, WordPress add target blank in all (a) html element.

I am personally not a fan of opening links in new windows ā€“ I think it should be left for the user to decide. But Iā€™m not one to judge, so if you want to do it, use this simple code snippet on your WordPress theme’s functions.php file.

WordPress code snippet:

function ns_autoblank($text) {
	$return = str_replace('<a', '<a target="_blank"', $text);
	return $return;
add_filter('the_content', 'ns_autoblank');


Find out more about functions here

Thank you for seeing my tutorial and fell free to share and comment šŸ™‚ . Do you have a code snippet and you want to see it publish on my site ? I will be more than happy to do it please send me a message (here)