WordPress Content Editor Default Links To New Tab/Window


About The Author
Cabe Nolan is the founder of WP Cover where he shares his insight into WordPress, development, & entrepreneurship. Outside of WPCover, Cabe continues to run a successful WordPress development firm, Bold City Design as well as a few high profile websites, Arrivala, Two Way Resume, Dock Skipper, and a successful outdoors brand, DolfinPack.







WordPress Content Editor Default Links To New Tab/Window

When writing a new blog post or creating a new page, you’ll often use the Link icon to embed new links into the content editor.  Most know that they can force the link to open in a new tab/window by ticking the checkbox when creating the link.

While the process is easy, it is an extra click.  Extra clicks equate to more human error.  I’ve had clients ask for this checkbox to be defaulted.  It’s a pretty quick little function that can be added to your themes functions.php file:

 

function default_blank_wp_tiny_mce() {
    ?>
    <script type="text/javascript">
    jQuery( function() {
        jQuery( 'input#wp-link-target' ).prop( 'checked', true );
    } );
    </script>    
    <?php
}
add_action( 'after_wp_tiny_mce', 'default_blank_wp_tiny_mce' );

Share Your Thoughts

Leave a Reply

Your email address will not be published.


Related Stuff You Might Like







WordPress News, Tips, & Code Snippets

Join the WP Cover mailing list and get wordpress news, tips, code snippets, security warnings, and more delivered right to your inbox.  We won't flood your inbox, newsletters typically go out every 1-2 weeks unless it involves an important security release.

You have Successfully Subscribed!