No results found. Try again with different words?

Search must be at least 3 characters.

Disable URL field in the Comment Section

Sidebar Image

Did not find a solution? We are here to help you succeed.

This guide will help you disable the URL field in the comment section of your WordPress site, specifically when using the Astra theme.

By removing this field, you ensure that comments remain relevant and prevent unnecessary links from cluttering your content.

We’ll show you two ways to do this: using a PHP code snippet or adding CSS.

Why Should You Disable the URL Field in Comments?

Disabling the URL field can help reduce spam comments, as spammers often use this field to leave irrelevant or malicious links.

It also simplifies the comment section, making it more user-friendly and focused on meaningful conversations.

How Can You Disable the URL Field?

You have two options for disabling the URL field:

  1. Using a code snippet in your child theme’s functions.php file.
  2. Using a simple CSS code via the WordPress Customizer.

1. How to Remove the URL Field Using a Child Theme?

Before editing any theme files, it’s always recommended to create a child theme to ensure your changes aren’t lost when the theme updates. If you don’t already have a child theme, check out this guide on installing an Astra child theme.

Here’s how to remove the URL field using PHP:

  • From your WordPress dashboard, go to Appearance > Theme File Editor.
  • In the top-right dropdown, select your Astra Child theme and click “Select.”
  • In the right-hand section, find and select the functions.php file.
  • Scroll to the bottom of the file and add this code snippet:
add_filter( 'astra_comment_form_default_fields_markup', 'astra_remove_comment_website_field', 20 );
function astra_remove_comment_website_field( $fields ) {
	unset( $fields['url'] );
	
	return $fields;
}
  • Click “Update File” to save your changes.

This code will remove the URL field from the comment form, preventing users from adding unnecessary links.

2. How to Remove the URL Field Using CSS?

If you prefer not to modify any theme files, you can easily hide the URL field with some CSS.

Here’s how:

  • Go to Appearance > Customize from your WordPress dashboard.
  • Navigate to Additional CSS, then copy and paste the following code:
.comment-form #url {
	display: none;
}
  • Click “Publish” to apply the changes.

This method will hide the URL field without modifying any theme files.

If you encounter any issues or need further assistance, feel free to contact us for additional support.

Was this article helpful?
Sidebar Image

Did not find a solution? We are here to help you succeed.

Related Docs

Join 1,653,898+ Happy Site Owners Using Astra

Whether you are a beginner, small business owner, or professional web developer, Astra provides all the tools you need to easily build your beautiful WordPress website.

REWIND

YEAR IN REVIEW

Download is Just A Click Away!

Membership Retention Checklist Download

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form
Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form