Disable Website field from comments & restyling the comments form

On the Blog Comments form I’d like to remove the Website field and have the Name and Email field span that row. With the Submit button on the next row. There is the following code that removes the Website field, yet I don’t know how to fix the rest of the formatting I want. When I use the code below the submit button appears on the same line as Name and Email.

add_filter(‘comment_form_default_fields’, ‘website_remove’);
function website_remove($fields)
{
if(isset($fields[‘url’]))
unset($fields[‘url’]);
return $fields;
}

Hey,

To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

Hi there,

Should be like this,

add_filter('comment_form_default_fields', 'modify_comment_fields');
function modify_comment_fields($fields)
{
unset($fields['url'], $fields['author'], $fields['email']);
return $fields;
}

You can check about the fields here https://codex.wordpress.org/Function_Reference/comment_form#.24fields

Thanks!

Where does this go?

Hello @kimelishap,

Please add the above code in child theme function.php file. Looks like you haven’t installed child theme. You can download from following resource: https://theme.co/apex/child-themes

Please refer following documentation to setup child theme: https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57

Thanks.

The code provided removes the entire line: name, email, and URL. I just want to remove URL.

Hi There,

Please update the previous code to this:

add_filter('comment_form_default_fields', 'modify_comment_fields');
function modify_comment_fields($fields)
{
unset($fields['url']);
return $fields;
}

That doesn’t work as it causes the original problem I contacted the forum about.

Hi there.

Thanks for the clarification. If the first code you have added in the child theme already removes the website URL field but the placement of the submit button should be changed, then you can stick this the PHP code you had in the beginning and you could add custom CSS to move the button.

The name and the email fields have the default width of 33.33333% and are floated to the left that is why the button goes adjacent to it when the URL field is removed. To solve this, you can simply increase the width of the name and the email field to 50% so that the two fields will fill the entire block and the button will be displayed in a new row. The CSS selectors that controls the name and the email are: .comment-form-email, .comment-form-author.

Hope this will get you started.

Cheers!

Thank you!

You are welcome!

Morning,

I tried adding add_filter(‘comment_form_default_fields’, ‘modify_comment_fields’);
function modify_comment_fields($fields)
{
unset($fields[‘url’]);
return $fields;
}

But the option is still there in the comments field?

Thanks

Hi @twoscotsabroad,

That code is based on https://codex.wordpress.org/Function_Reference/comment_form#.24fields

It should work unless it’s being overridden. I recommend starting a new thread and provide your admin and FTP login credentials in a secure note of that thread. For the meantime, please try this

add_filter('comment_form_default_fields', 'modify_comment_fields', 99999999999 );
function modify_comment_fields($fields)
{
unset($fields['url']);
return $fields;
}

Thanks!