How to remove native URL field from WordPress comments

The way comments are usually left on said platform has changed over time. In this way, the owner of the post has been given greater power, so that he is the one who has the power to decide and configure the settings of the comments that will be hosted there.

This is given for the sole purpose that social networks and website communities are a safe and optimal space for all users to discuss their ideas, without feeling offended or in danger.




How to remove native URL field from WordPress comments

How to hide the comment field from CSS

This is one of the simplest first options to make. With it you can get to hide the web field that has the code CSS. If the theme you have respects the default classes of your WordPress page with respect to comments, you can use the following code:

.comment-form-url {

display: none;

}

You can put it inside a CSS file of your own theme, so we recommend doing this within your child theme's style.css file.

With this method you can hide any type of element that matches a class, which by default in WordPress the system rejects them, however, these are elements that within a form you have to be careful with respect to hiding some fields that are usually required.

What is the code in functions.php?

If what we want to do is delete the web field long before it appears in the browser, we can use the comment_form_default_fields hook and thanks to a filter we will proceed to eliminate within the field. For this, you will need to enter the following code, however, you should be careful to do it right at the end of the file functions.php.




function dcms_disable_url_comment (campi $) {

unset ($ campi [‘url’]);

returns the fields $;

}

add_filter (‘comment_form_default_fields’, ‘dcms_disable_url_comment’);

Within the above code, you should know the following important points:

  • Start applying a filter solo con l’hook comment_form_default_fields
  • This filter refers to what we can call the dcms_disable_url_comment () function
  • This function accepts the $ fields code which is the array with respect to the fields to display
  • Likewise, simply by using the code unset () we can identify the ID of said element that is inside the array and that we want to delete
  • Finally, we need to go back to the $ fields array again

How to remove native URL field from WordPress comments


How to enable comment moderation

In this next option you can prevent various comments that are considered spam within WordPress, all thanks to various functionality integrated. In the first one we will try, we can find the one that is manual in nature.



However, this will not reduce spam within comments, but it may be more effective as it ensures that all visitors to the site will only see the high quality comments approved by you.

Inside the second is the line that corresponds to the moderation of comments, this corresponds to the action automatic, since if it has a word, name or URL that you have specified as spam, the system will either delete it or just omit it from what other users don't see.


add a comment of How to remove native URL field from WordPress comments
Comment sent successfully! We will review it in the next few hours.