Skip to:
Content
Pages
Categories
Search
Top
Bottom

open link within replys in a new window

  • @barabajen

    Member

    I´ve seen a couple suggestions to do the above. But it seems it needs to be more simplified for me to make it work.

    So could anyone explain how to make it happen – in a “for dummys”-way.

    I thought i had the hang of it – but noo.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • @kawauso

    Member
    <?php
    /*
    Plugin Name: Open Links in New Window
    */

    function bb_target_blank( $text ) {
    $text = preg_replace('|<a (.+?)>|i', '<a $1 target="_blank">', $text);
    return $text;
    }
    add_filter('post_text', 'bb_target_blank',255);

    ?>

    Put the above into a file and save it as new-window-links.php or similar in your my-plugins directory. Then enable it in the plugins menu. Should work. Avoid getting any spaces around the start and end tags.

    https://bbpress.org/forums/topic/target-_blank

    @barabajen

    Member

    Kawuso,

    feeling a like I´m starting to be a bit annoying for you now. But when i activate the plugin it just makes any link with in a thread unclickable.

    What have I done wrong?

    @kawauso

    Member

    Argh it ate part of it. Check the link and copy the line opening $text from there instead. There’s meant to be $1 in-between the spaces before target.

    @barabajen

    Member

    Again kawuso,

    thanks a million times!

    @invtrdr

    Member

    Hey Kawuso. Can you re-post the correct code. I am having the same problem as BaraBajen had.

    Thanks.

    @invtrdr

    Member

    Got it to work. Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar