Reputation: 99
i have Genesis Magazine Pro Theme and i want to delete comment author link.
I use many different guide:
http://wpsquare.com/remove-comment-author-website-link-wordpress/
https://www.engagewp.com/remove-wordpress-comment-author-link/
I add some code in functions.php, but these method doesn't work
I have still remove the field link when someone post a comment, but now i want to remove the comment author link.
How to resolve it?
For example, i want to remove the link on "Mr Wordpress".
Upvotes: 2
Views: 2009
Reputation: 29
This function will remove whole comments having links at once make sure you adjust the PHP allocated memory limit according to the amount of comments
// Check if the function exists before declaring it
if ( ! function_exists( 'delete_comments_with_links' ) ) {
function delete_comments_with_links( $comment_id ) {
$comment = get_comment( $comment_id );
// Check if the comment content contains links
if ( preg_match( '/http(s)?:\/\//i', $comment->comment_content ) ) {
wp_delete_comment( $comment_id, true ); // Delete the comment
}
}
}
Upvotes: 0
Reputation: 115
In case that you don't want to do it directly on Genesis, you can paste this filter at the end of your theme functions.php file:
function filter_get_comment_author_url( $url, $id, $comment ) {
return "";
}
add_filter( 'get_comment_author_url', 'filter_get_comment_author_url', 10, 3);
Enjoy!
Upvotes: 3
Reputation: 115
You have to go to:
genesis > lib > structure > comments.php
And find the following line:
if ( ! empty( $url ) && 'http://' !== $url ) {$author = sprintf( '%s', esc_url( $url ), genesis_attr( 'comment-author-link' ), $author );}
And replace it with this new:
if ( ! empty( $url ) && 'http://' !== $url ) {$author = sprintf($author );}
Upvotes: 0