Skip to content

Snippet: Open Entries with Redirection in a New Tab

add_action( 'wp_footer', function() { ?>

	
		( function( $ ) {
			'use strict';
			$( document ).on( 'ready', function() {
				var $entriesWithRedirect = $( '.has-redirect' )
				$entriesWithRedirect.each( function() {
					var $this = $( this );
					$this.find( 'a' ).attr( 'target', '_blank' );
				} );
			} );
		} ( jQuery ) );
	

<?php } );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top