Ticker

6/recent/ticker-posts

Ad Code

Responsive Advertisement

How to remove Comment Author Link from Existing WordPress Comments and Submit Form

In this tutorial we will go over steps on how to remove Comment Author Link and Website text area from WordPress comment form.

Let’s get started:


1. Remove Comment Author link from all existing WordPress comments

Before:

As you see here at bottom left corner, user’s link is easily clickable while hovering cursor over to Name in existing WordPress comment. How to remove Author link across all comments?

Remove Comment Author link from all existing WordPress comments - Before

In order to remove author link, just put below code into WordPress’s functions.php file and you are all set.

function crunchify_remove_comment_author_link( $url, $id, $comment ) {
    return "";
}
add_filter( 'get_comment_author_url', 'crunchify_remove_comment_author_link', 10, 3);

Here we are using get_comment_author_url WordPress filter. It retrieves the URL of the author of the current comment, not linked.

After:

Here is a screenshot after adding above code. As you see here, there is no URL for an author.

Remove Comment Author link from all existing WordPress comments - After

2. Remove Website field from Comment Submit Form

WordPress by default gives you an option to provide Website URL while submitting form. What if you want to remove Website field from WordPress comment form?

Before:

WordPress Comment Form with URL field - Crunchify Tips

Well, solution is very simple. Just add below comment_form_field_url filter and return false and Website field wont be visible on Comment form. It formats the HTML-formatted output of the comment form field.

add_filter('comment_form_field_url', '__return_false');

After:

Here is a screenshot of our Comment form after adding above to functions.php file.

WordPress Comment Form without URL field - Crunchify Tips

I hope this helps you fine tune WordPress comment form based on your need.

We do have a detailed on on how to customize WordPress comment form.

The post How to remove Comment Author Link from Existing WordPress Comments and Submit Form appeared first on Crunchify.

Enregistrer un commentaire

0 Commentaires