WordPress.org

Ready to get started?Download WordPress

Ideas

Default Links to Open in New Window - i.e. Target = _blank

  1. Eva Marie
    Member

    Hello I am facing a problem in WordPress that if I add any link in my WordPress website page, after that when I click on that link it is opening in new tab that is irritating. I want to fix this problem. Anybody can help me to solve this issue. Here is my WordPress website http://www.essaybingo.com/.

    Thanks

    Eva Marie

    Posted: 6 months ago #
  2. Ian Dunn
    Member

    12345

    Hi Eva, this forum is for ideas to improve WordPress itself. The best place to post your issue is in the support forums at http://wordpress.org/support/

    Posted: 6 months ago #
  3. Eva Marie
    Member

    Ian Dunn, thanks you so much. Hope so this will be helpful for me :(.

    Posted: 6 months ago #
  4. bgal2012
    Member

    I know this is old, but if I found it today while I've I've been trying to do this then others probably do too... I finally found something worked.

    Add this to the bottom of your theme's function file (back up your site before messing with code):

    'function autoblank($text) {
    $myurl = 'http://puryourdomainhere.com';
    $external = str_replace('href=', 'target="_blank" href=', $text);
    $external = str_replace('target="_blank" href="'.$myurl, 'href="'.$myurl, $external);
    $external = str_replace('target="_blank" href="#', 'href="#', $external);
    $external = str_replace(' target = "_blank">', '>', $external);
    return $external;
    }
    add_filter('the_content', 'autoblank');'

    I still have one link not cooperating, but it's from a plugin. Still working on that. All other external links on site are now opening in new tab :)

    Hope it helps.

    Posted: 1 month ago #
  5. stevemanser
    Member

    For creating links in menus that open in a new window; just click on Screen Options top left, all will become clear....

    Posted: 2 days ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    10 Votes
  • Status

    This is plugin territory