Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Comments, trackbacks & pings (http://forum.bytesforall.com/forumdisplay.php?f=19)
-   -   [SOLVED] Open Comment Author link in new window (http://forum.bytesforall.com/showthread.php?t=3593)

Larry Sep 25, 2009 08:19 AM

[SOLVED] Open Comment Author link in new window
 
I would like to have the hyperlink for the Author of any comment who provides a website url, to open in a new window. I searched the forum here already with no luck.

I know I can use target="_blank" but can't find where the best place to add this would be. :confused:

Larry Sep 25, 2009 06:53 PM

Never mind, I got it taken care of.

juggledad Sep 26, 2009 06:49 AM

Mind explaining your solution to help someone else that might want to do this?

Larry Sep 26, 2009 07:53 AM

Certainly, as soon as I remember what I did:o
Once I get started on something, I can't seem to stop. I know I spent quite a while getting ti to work. I will go through my notes and post back what I did.

Larry Sep 26, 2009 08:26 AM

Okay, here's what I did (if there is an easier way or better way, please correct my post):

1) Logged in to C-Panel to get access to wp-includes/comment-template.php
2) Opened up comment-template.php using the code editor in C-Panel
3) Located the function get_comment_author_link which was on line 148 in my file
4) Here is what the code looked like before I made the change:
Code:

function get_comment_author_link() {
        /** @todo Only call these functions when they are needed. Include in if... else blocks */
        $url    = get_comment_author_url();
        $author = get_comment_author();

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

5) Here is what it looked like after I added target='_blank'
Code:

function get_comment_author_link() {
        /** @todo Only call these functions when they are needed. Include in if... else blocks */
        $url    = get_comment_author_url();
        $author = get_comment_author();

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

6) Save the edited file in C-Panel and then preview a page with a comment on it to make sure it works.


All times are GMT -6. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.