• Ok so i need some help. When someone adds a comment on my blog and i click their link, it doesen’t open in a new window. Please can anyone help me fix this?

Viewing 12 replies - 1 through 12 (of 12 total)
  • This is not the default behavior of WordPress…. You’d have to hack into the core to change it.

    In wp-includes/comment-functions.php, find:

    function get_comment_author_link() {
    global $comment;
    $url = get_comment_author_url();
    $author = get_comment_author();

    if ( empty( $url ) )
    $return = $author;
    else
    $return = "<a href='$url' rel='external nofollow'>$author</a>";
    return apply_filters('get_comment_author_link', $return);
    }

    Change the return line to:
    $return = "<a href='$url' rel='external' target='_blank'>$author</a>";

    Note that the target attribute is not valid XHTML 1.0 Strict, but its up to you if you care about that.

    Instead of target="_blank" you can use onclick="window.open(this.href);return false;" – works just fine.

    Sorry, I learned HTML before all this fancy script stuff ??

    *laughing* S’okay, not really a script, just a different way to do the whole “open elsewhere” thingy. What I posted above is used, for instance, like this: <a href="https://example.com/index.php" onclick="window.open(this.href);return false;"> – basic html addy that opens a new window.

    I don’t see any reason it wouldn’t work for the href in the $return call, though of course, I could easily be wrong. (I quite frequently am!)

    Thread Starter joeistoxic

    (@joeistoxic)

    Could someone do it for me please?

    Thread Starter joeistoxic

    (@joeistoxic)

    Shit i just buggered it up. It doesen’t say who commented now, it just says Says:

    Please help..

    Thread Starter joeistoxic

    (@joeistoxic)

    [Moderated – huge code chunk deleted]

    Thread Starter joeistoxic

    (@joeistoxic)

    Anyone? Please..

    Sorry been studying for final exams.

    Here is the version that works for me (WP 1.5 only)

    Save this as comment-functions.php, and put it in your /wp-includes/ directory. Should be all set after that.

    is these for the comments post body enter https://fghhh.com/ then click on link while viewing comment in blog open in new windows?

    Any moderators around to delete all that code above?

    Thread Starter joeistoxic

    (@joeistoxic)

    It worked ! Thank you so much!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Comments Help’ is closed to new replies.