WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] "hack" so that link will include "target=new" (9 posts)

  1. eveums
    Member
    Posted 9 years ago #

    Not sure if this is possible or not...

    Currently, when I am adding a link to my post, I am prompted for a URL and then the URL is plopped into my post. I would like for the URL to be plopped into my post ALONG WITH a "target='new'" or similar code.

    Anyone have any ideas? Thanks!!!!

  2. Kafkaesqui

    Posted 9 years ago #

    Edit wp-admin/quicktags.js so it will be added automatically. Look for this function near the end of the js file:

    edInsertLink(myField, i, defaultValue)

    In the function change this line:

    edButtons[i].tagStart = '<a href="' + URL + '">';

    to:

    edButtons[i].tagStart = '<a target="_new" href="' + URL + '">';

  3. eveums
    Member
    Posted 9 years ago #

    Thanks!! :)

  4. 5starAffiliatePrograms
    Member
    Posted 9 years ago #

    Hey Kafkaesqui,

    I was trying to figure that out too. Just made the edit, but links still do not open in new window. Any other ideas???

    Thanks, Linda

  5. Kafkaesqui

    Posted 9 years ago #

    Linda:

    1. If you edited quicktags.js offline, you uploaded it to the correct directory (wp-admin/)?

    2. If your in the WP edit panel at the time, did you perform a hard-refresh of the page to reload the Quicktags javascript?

    3. You're using the link Quicktag button to enter links in your post?

  6. 5starAffiliatePrograms
    Member
    Posted 9 years ago #

    Yes thanks I did all that and double checked it. Plus just tried again after hard refresh. I'm not a coder but your instructions were great and I'm sure I did it right.

    Can you tell anything by looking at my source code?
    http://affiliate-blogs.5staraffiliateprograms.com/

    Thanks so much!

  7. 5starAffiliatePrograms
    Member
    Posted 9 years ago #

    Nevermind - got it to work! I had only hit refresh before. Had to close my FF browser and then open a new one and it worked. Thanks this is AWESOME!!!

  8. seth
    Member
    Posted 9 years ago #

    target="_new" is deprecated. A better way is to add rel="external" and then use this code.

  9. notthatugly
    Member
    Posted 9 years ago #

    target="_new" is annoying. A better way is to let your readers decide for themselves whether they want to open a new browser window.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags