Open All Links in New Windows

 In Themes

Open All Links in New Windows

I am personally not a fan of opening links in new windows – I think it should be left for the user to decide, as I explained in this post. But I’m not one to judge, so if you want to do it, use this simple code snippet:


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


One thing I should add is that the above HTML is not XHTML strict compliant. If you do want to be compliant, you should use the plugin.

Recommended Posts

Start typing and press Enter to search