How to Make Link Tag in WordPress Post/Page Editor Become Open In New Tab/Window by Default

This following modification will change the javascript files that belong to WordPress core, in order to make the Link tag in WordPress post/page editor become open in new tab/window by default. As we know, by default in WordPress, this tag will open in the same window since there is no target=”_blank” property in the a href, especially if you insert this tag by typing your post/page from HTML tab (not from Visual tab) on your WordPress’ post/page editor. As this will change the core file of your WordPress, then you have to change the related files if you upgrade your WordPress core installation. So, please be kind, everyone!

  1. Open your /wp-includes/js/quicktags.js file, and find this code:

    if(a){edButtons[c].tagStart='<a href="'+a+'">';

    then replace with this following code:

    if(a){edButtons[c].tagStart='<a href="'+a+'" target="_blank">';
  2. Open your /wp-includes/js/quicktags.dev.js file, and find this code:

    144
    
    	this.newWin = 0;

    then replace with this following code:

    144
    
    	this.newWin = 1;  // Modified by Masino Sinaga, July 10, 2010, in order to add target="_blank" phrase while creating new link

    Find again this code:

    216
    
    		var newWin = '', tempStr;

    then replace with this following code:

    216
    
    		var newWin = '1', tempStr;  // Modified by Masino Sinaga, May 20, 2010, in order to add target="_blank" phrase while creating new link

    Find again this code:

    451
    
    			var newWin = '', tempStr;

    then replace with this following code:

    451
    
    			var newWin = '1', tempStr;  // Modified by Masino Sinaga, May 20, 2010, in order to add target="_blank" phrase while creating new link
  3. Clear your browser’s cache that you are currently using, afterwards close and re-open your browser, then try to login to your editor’s post/page via “HTML” tab in your WordPress, then try the Link tag. You should see that WordPress has automatically added the target=”_blank” phrase inside the Link a href tag.
Share

2,542 viewsPrint This Post Print This Post

Comments

  1. 3Fortune says:

    Infonya pas banget, mendarat disini dari hasil gugling, salam kenal semoga sehat dan sukses selalu

  2. Isn’t the WordPress editor frustrating? There is a list of more than a dozen WordPress Editors at http://bloggerkhan.com/what-is-the-best-editor-for-wordpress/33 I have started experimenting with two. Let’s see.

  3. Vali says:

    But do you know a way to automatically add the target=”_blank” phrase to the links in comments. This will be very usefull. Thanks!

Speak Your Mind

*


*