Snippets: Open Entries with Redirection in a New Tab

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

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

<?php } );

Snippet Type: PHP

Posted Under: Other

All PHP snippets should be added via a child theme's functions.php file.