Search
Close this search box.

How To Remove URL Field From Comments in GeneratePress

Affiliate disclosure: In full transparency – some of the links on our website are affiliate links, if you use them to make a purchase we will earn a commission at no additional cost for you (none whatsoever!).

How To Remove URL Field From Comments in GeneratePress, A question that I regularly see come up on the GeneratePress support forums and Facebook groups is: “How can I remove the URL field from comments in GeneratePress?”.

You can easily remove the website field from the WordPress comment box using the plugin method. From the URL field, there are various plugins to try and get freed.

In addition, we will remove the website box by using a child theme method and code snippets in the functions.php method. Before diving into the article check out our detailed guide on GeneratePress Review

Methods to Remove Website Field from the Comment form

1. By using Remove URL Field Plugin

In WordPress, the URL field can be hidden or removed by simply adding a plugin.

The GeneratePress Theme did not work with any of the plugins in the WordPress repository. To remove the URL field from the comment form, I created a simple plugin.

Within WordPress

  1. Visit ‘Plugins > Add New’
  2. Search ‘Remove URL Field from Comment Form in GeneratePress Theme’
  3. Install and Activate the plugin.

Manual Way

Plugins can be downloaded and installed. GeneratePress Theme comes in both a free and premium version.

  • Use the above link to download the plugin.
  • Go to Plugins > Add New.
  • Upload the plugin by clicking on it.
  • Install the plugin and activate it.
  • The comment box has been updated.

Let’s take a look at how you can go about removing the URL field from your comment form! 💡

How To Remove URL Field From Comments in GeneratePress

The comment_form() function generates a dynamic form for users to leave their messages. The template has two rows. One for entering your name and email (required), and one for entering the comment (optional).

By default, the second row includes a standard HTML Textarea element along with an input field specifically for URLs. To remove this text area entirely, we need to pass it through our own custom whitelist using CSS classes provided by GeneratePress.

I’m using GeneratePress version 2.5.1 for this tutorial, but the steps should work the same on older versions too.

To remove the URL field from comments in GeneratePress first head over to your WordPress Dashboard and navigate to Settings » Comments. Here you’ll find the Comment Form settings section that we’re looking for:

The Default Comment Form settings editor screen (GeneratePress v2.5.1).

Remove default fields by adding them to the blacklist Selecting fields to blacklist… Add “URL” class If you feel comfortable with editing CSS manually, try identifying which of these fields are generated using the HTML <label> element where input is wrapped inside label > like so: Note: You can use this free online tool to Identify HTML Elements In Your Browser.

In my case, I want to remove the URL label from the comments form, so I’ve added a CSS class of “URL” to identify it in my custom stylesheet.

After clicking “Save Changes”, take a look at your comment form and you’ll notice that the URL field is no longer there: Comment Form without any fields marked as blacklist – GeneratePress v2.5.1 We can see that instead of an empty text area, there’s now just black space where the URL field used to be!

If you’re wondering if this was really that easy then yes – it absolutely is! 😎 You can do some cool stuff by altering the styling of the existing GeneratePress comment form fields.

In the next step, we’ll cover how to remove the optional URL field from comments entirely. To do that we need to find where the comment form is being output and take a look at each line of code.

The Comment Form Output section Has two sections: 

The default first level of output… …and second level of output where child elements are identified by classes “child” and “children”. To disable a given element within a parent element you must first identify its CSS Class or ID as well as its parent’s class/ID to determine where it will appear in your stylesheet.

In this case, our goal is to remove an element that is labeled as a child with a class of “children”. So, wherein in the stylesheet would we find that? Well, it turns out that comment_form.php has two different output options for us to use:

..and here’s the second level of output using “children”: This is perfect! Our element with a class of “children” (our label) is only used when specifying children. The trick to disabling it will be found in comments.php, which you can open up by clicking on the expand button next to comments : 

Here’s relevant portion of code used for rendering comments within WordPress loop showing how our URL field comes into play: <div id=”respond”> <?php if ( have_comments() ) : ?> <!– Comment Form –> <?php if ( post_password_required() ) : ?comment_form(array(‘post_id’ => get_the_ID(), ‘nopriv’ => true)); else : ?> <!– You can use comment form object to retrieve user data –> <?php comment_form(); ?> <!– Display comments list. No pagination. –> <?php endif; ?> </div><!– #respond –> Now if you’re unfamiliar with programming/PHP you might be wondering, “Can’t I just edit the file with this code in it and delete the URL field point-blank?” Of course! It would work… But there’s a problem… Disabling unnecessary HTML tags with CSS classes is often how WordPress developers make changes without breaking the site. 

Unfortunately, some HTML tags are not allowed to be deleted, so instead, they can be populated with blank content by adding an HTML comment within your stylesheet. The CSS comment syntax is used to tell browsers to ignore it while parsing the style sheet: /* this is a single line comment */

Conclusion: How To Remove URL Field From Comments in GeneratePress

If you are looking for a quick solution to removing URL fields from comments in GeneratePress, then this post will surely help you. We have looked at easy ways to remove URL fields from comments in GeneratePress. Hope the post was helpful to you, please do share it with others too.

Thank You…!

Diksha Dutt

A graduate of the IIMC, Diksha enjoys talking about self-growth and online learning platforms. Diksha has a passion for education and entrepreneurship, and she has been involved in both fields for over a decade. She aims to help others make more informed decisions about the best online resources, courses, and education platforms. She writes about online learning platforms and online courses on Megablogging.org, where she reviews and recommends the best resources for different skill levels and goals. When Diksha is not working, she enjoys reading books, playing chess, and traveling with her husband and two kids. You can follow her on LinkedIn and FaceBook.

Leave a Comment

0 Shares
Tweet
Share
Share
Pin