Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Open outside links in a new tab

Links in your posts and pages that go to other sites open in a new tab. Menus and footers aren’t changed.

  • Type JavaScript
  • Runs Public site, before </body>
  • Tested with WordPress 7.1
JavaScript
// Only links inside post and page content.
document.querySelectorAll( '.entry-content a[href], .wp-block-post-content a[href]' ).forEach( function ( link ) {
	if ( /^https?:$/.test( link.protocol ) && link.hostname && link.hostname !== window.location.hostname ) {
		link.target = '_blank';
		if ( ! /\bnoopener\b/.test( link.rel ) ) {
			link.rel = ( link.rel + ' noopener' ).trim();
		}
	}
} );

In these packs

  • Content and media: Shortcodes, links, images and small design touches for the public site.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.