How to modify the comments author link to link to his profile instead or the author posts page

You can change it by adding this filter to the child theme functions.php file. 

function xt_child_comment_author_profile_link(){
    /* Get the comment author information */
    global $comment;
    $author_id = $comment->user_id;
    $author = get_comment_author( $author_id );
    $url    = get_comment_author_url( $author_id );
    /* Return the default WordPress comment author link if comment author is not
    a registered user */
    if ($author_id == 0){
        if ( empty( $url ) || 'http://' == $url )
            $return = $author;
        else
            $return = "<a href='$url' rel='' class='author-url'>$author</a>";
    } else {
         /* Return the link to the comment author's profile page if otherwise */
        $return = get_author_posts_url( $author_id );
    }
    return $return;
}
add_filter('get_comment_author_link', 'xt_child_comment_author_profile_link');
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us