[resolved] links in posts and pages editor to add target="_blank" by default? (6 posts)

  1. datahound
    Posted 10 years ago #

    Brand new to WP what a treat!

    I have some knowlege of PHP, I would like to know where I can edit the line that wraps the a href code around the link when you create a link in post or page, so it can include target="_blank" as standard.

    Thanks in advance.

  2. petit
    Posted 10 years ago #

    If you want all links to open in a new window, you'd like to set _blank as the default target. You can do this by inserting the following in the header section header.php:
    <base target="_blank" />

    It is also possible that you can add target="_blank" in your post using the html editor. I haven't tested it and it is quite possible that it will be filtered out, as it is not part of xhtml.

  3. datahound
    Posted 10 years ago #

    I searched before I posted and that was a solution offered (<base target="_blank" />) in an earlier post, but that is not what I want to achieve.

    At the moment I am editing manually in the html editor and adding the target="_blank" text in every link. It does not get filtered out. I know purists might find it vulgar but I prefer the new window.

  4. niziol
    Posted 10 years ago #


    I've been using this plugin Zap New Window. Just install and activate the plugin, it will add some javascript to the head of each page and force all externals links (ie: outside of your domain) to open in a new window. It uses javascript, so visitors (I assume) would have to have it enabled for it to work.

    Good luck,

  5. datahound
    Posted 10 years ago #

    Thanks very much Niziol, worked a treat.

  6. romaba
    Posted 9 years ago #

    thanks petit, that was very helpful.

Topic Closed

This topic has been closed to new replies.

About this Topic