How to Remove URL Field from Generatepress Comment Form?

Getting unwanted comments with spammy URLs on the WordPress website? Here in this article, we are going to solve the issue. I am going to take reference of the GeneratePress theme, however, if you are using any other theme, these methods will also apply to it. So, I will share with you, how to remove URL field on the GeneratePress theme/or other.

So, there are simple three methods, that you can use to remove/hide the URL field on any WordPress website.

  1. CSS to hide the URL field.
  2. Using Third-party Plugin
  3. Using PHP code snippet

If you are using the GeneratePress theme, then our recommendation is to use PHP code to remove the URL field from the comment box. However, if you don’t want to modify codes, then the simplest method, using a plugin to remove the URL field, you can use it.

Why should you remove the URL field from your WordPress site’s comment box?

You might consider removing the URL field from the comment section in WordPress because there are some specific reasons as listed below:

Spam: Comment boxes on WordPress sites attract a lot of spam comments, even if the comments are legit, lots of users post bad links with irrelevant comments. Therefore to stop spamming, removing the URL field is a great option for moderation.

Engagement: Comments can encourage user engagement and conversation, but if your comment section has off-topics or spam, it will impact badly on engagement. Therefore removing the field URL field or comment box, would help overall site health.

How to Remove URL Field in GeneratePress?

As I mentioned above, there are various methods to remove or hide the URL field from GeneratePress or any WordPress theme. We are going to use these three methods, listed below:

Remove the URL Field Using CSS code.

CSS for Removing URL Field from GeneratePress

This method will work with all websites which use WordPress. You have to add a line of CSS code, which will hide the URL field from the website. To add CSS, login to the WordPress dashboard, then hover your mouse on “Appearance” & click on “Customize”, then select “Additional CSS” to add custom CSS code.

Add Custom CSS to Remove URL field in GeneratePress
Adding CSS in WordPress Customizer
.comment-form #url {
Display: none;
}

Add this CSS code to the WordPress theme customization setting, you will see that, the URL field will be gone.

Must Read: How to Add Reading Progress bar on GeneratePress?

Remove the URL Field Using PHP codes

We can also remove the URL field from the WordPress comment section, using PHP codes, & it can be used in any WordPress theme. There are two methods of adding the codes, you can use a third-party plugin like “Code snippet” or simply add the PHP code in the fuction.php file, by using WordPress’s native “Theme File Editor”.

Adding PHP Snippet to Function.php
Add PHP code in function.php

In this tutorial, I have used the Theme File Editor method, which is more convenient & not need to install an extra plugin, which will impact performance.

/* Remove URL Box Comment */
add_action( 'after_setup_theme', 'tu_add_comment_url_filter' );
function tu_add_comment_url_filter() {
    add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 );
}
 
function tu_disable_comment_url($fields) {
    unset($fields['url']);
    return $fields;
}
/* Remove URL Box Comment */

Above mentioned these lines of PHP code, copy, and paste on your site’s fuction.php file. Adding codes or modifications could break your WordPress site, so before doing anything I suggest you install a Child theme & then add these lines of code.

After adding the PHP snippet, you will see that the URL field is gone from the comment box.

Must Read: GeneratePress Vs Genesis: Check out which one is the fasted WordPress theme.

Remove URL Field Using Third-party Plugin

The final method to remove the URL field from the comment form of a WordPress website is using the plugin “No URL Field”. This plugin is contained the PHP code which is mentioned above. This plugin method is for those users, who don’t want to play with codes. Therefore download the plugin and Install it on your WordPress site. The URL field will be removed without adding CSS or PHP.

Conclusion

I hope using one of these methods, you have resolved your URL removal issue. WordPress is one of the most popular CMS platforms, & it comes with many features, that are unnecessary for certain users, so WordPress gives you the freedom to customize it.

To remove the URL field from the GeneratePress theme or others, you can use any of the methods. I personally suggest using the second method, which is adding a PHP snippet.

However, tell us in the comment, which method you have used & which one seems easy. If you have any questions or concerns, you can also leave a comment, I will try to help out.  

Recommend Articles:


Pronay Sarkar

Hello!
I am Pronay Sarkar, I love to write about tech and stuff. I am a college graduate from the University of Delhi.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.