Remove author link from recent comments widget

42 Views Asked by At

1st of all, I know how to add custom widget, BUT! I want to use default WP widget of recent comments. And by default the author's name - is a link to his URL, or on his page on this site... like : site.com/author/author_name . I'm looking for hook to remove this. On front-end it looks like: <a class="wp-block-latest-comments__comment-author" href="site/author/authorname/">authorname</a> I found in /wp-includes/blocks/latest-comments.php some condition:

            $author_url         = get_comment_author_url( $comment );
            if ( empty( $author_url ) && ! empty( $comment->user_id ) ) {
                $author_url = get_author_posts_url( $comment->user_id );
            }

And anyway in that @name@ - link.... how to remove this? Make some like: <b>Authorname</b>

I tried a bunch of methods and no effect...

add_filter( 'get_comment_author_link', 'remove_comment_author_link', 10, 3 );

function remove_comment_author_link( $author_link, $author, $comment ) {
    return esc_html( $author );
}

no effect

This hook can change URL:

function recents_comments_output_change( $url, $id) {
    $url = get_comment_link($id);
    return $url;
}

add_filter( 'get_comment_author_url', 'recents_comments_output_change', 10, 3);

But how to remove?

This hook can remove NAME, from URL....but not URL...

function remove_comment_author($author, $comment_ID, $comment) {
return ''; 

}

add_filter('get_comment_author', 'remove_comment_author', 10, 3);

0

There are 0 best solutions below