Auto convert WordPress post content URLs to Hyperlinks and open in a new window
I needed to have all of my post content plain text URLs converted to Hyperlinks, but it needs to open in a new window when clicked. The make_clickable() function in wordpress doesn’t allow to specify any option for the target. function make_clickable2($content) { $content = preg_replace("/http:\/\/[a-zA-Z.&\-\/]+[a-zA-Z&\-\/]+/", "<a href=\"\${0}\" target=\"_blank\">\${0}</a>", $content); return $content; } add_filter('the_content', 'make_clickable2');


1128
21
3
0
0
1059
57
55
15
11
1
0
0
0
0
0
0