Created
February 18, 2018 19:56
-
-
Save gstricklind/b2dd7d5bd1b60a3b7a2f664f2d6b687f to your computer and use it in GitHub Desktop.
Open ALL links in new tab for a custom post type or page template type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use this code in your page template where needed | |
function gs_target_blank($content) { | |
$post_string = $content; | |
$post_string = str_replace('<a', '<a target="_blank"', $post_string); | |
return $post_string; | |
} | |
add_filter( 'the_content', 'gs_target_blank' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment