Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Open ALL links in new tab for a custom post type or page template type
// 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
You can’t perform that action at this time.