Mike Haydon

Web 2.0, SEO, Internet Marketing and Life in General

Mike Haydon

Edit the ‘Link’ Button in Wordpress

April 27th, 2008 · 1 Comment

I’m sick of having to put rel=”nofollow” and target=”_blank” into every tag when I’m posting (I am currently using Wordpress 2.5.1 on my own host). I thought “there’s gotta be an easier way”. There must be a way I can edit the “link” button to add those html attributes automatically… There is.

This is how to edit a button on the Wordpress composition panel:

Open the file wp-includes/js/quicktags.js in Wordpad (I don’t know the Mac equivalent). Notepad won’t let you see the file properly because it doesn’t read the line-breaks correctly.

Scroll down to the code where it says:

function edInsertLink(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = ‘http://’;
}
if (!edCheckOpenTags(i)) {
var URL = prompt(quicktagsL10n.enterURL, defaultValue);
if (URL) {
edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘”>’;
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}

change the line:

edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘”>’;

to read:

edButtons[i].tagStart = ‘<a href=”‘ + URL + ‘ rel=”nofollow” target=”_blank”>’;

save the file (ftp to your site) and you’re done! It’s that simple :razz:

PS. If you want to edit any of the other buttons, or add your own, such as a <h1> button, there is an excellent tutorial on editing wordpress buttons.

Popularity: 35%

Tags: ,

1 response so far ↓

  • 1 Mike Haydon // Apr 27, 2008 at 4:08 pm

    One thing I just noticed… If you are using firefox and this solution doesn’t work for you, you need to clear the cache. Press Ctrl+Shift+Del, make sure “Cache” is selected, then press “Clear Private Data Now”. Refresh the page and this will work.

Leave a Comment