How to Customize the Comment Form in the Twenty Twenty Theme
Content
Customizing the comment section is a common request for users of the Twenty Twenty theme. Whether you want to change the text, reorder fields, adjust styling, or remove elements like the website URL field, this guide covers the most effective methods.
Common Comment Form Customization Requests
Based on community discussions, users frequently want to:
- Change the "Leave a Reply" heading and notes text.
- Remove the website URL field from the comment form.
- Alter the visual styling (fonts, borders, button colors) with CSS.
- Reorder the position of elements, such as moving notes below the email field.
- Keep comments permanently expanded instead of having them scroll into view.
Method 1: Using a Child Theme and Filters (Advanced)
The most powerful way to modify the comment form is by using WordPress filters in your child theme's functions.php file. This approach allows you to change the form structure and fields without editing core theme files.
Removing the Website URL Field
To remove the website field, add the following code to your child theme's functions.php file:
function twenty_twenty_remove_comment_url($fields) {
if(isset($fields['url'])) {
unset($fields['url']);
}
return $fields;
}
add_filter('comment_form_default_fields', 'twenty_twenty_remove_comment_url');
Changing the "Leave a Reply" Text and Notes
To modify the text strings, use the comment_form_defaults filter:
function twenty_twenty_modify_comment_strings($defaults) {
$defaults['title_reply'] = 'Your Custom Heading Text';
$defaults['comment_notes_before'] = 'Your custom text before the fields.';
return $defaults;
}
add_filter('comment_form_defaults', 'twenty_twenty_modify_comment_strings');
Method 2: Styling with Custom CSS
For visual changes like fonts, borders, and button styles, use the Customizer's "Additional CSS" section.
Example: Styling the Comment Button and Inputs
The following CSS adds rounded corners to the input fields and the submit button, changes the button color, and capitalizes its text.
/* Style input fields and textarea */
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
border-radius: 8px;
}
/* Style the submit button */
.comment-form input[type="submit"] {
border-radius: 8px;
background-color: #0073aa;
text-transform: uppercase;
}
.comment-form input[type="submit"]:hover {
background-color: #005177;
}
Method 3: Using a Plugin
For users who are not comfortable with code, several WordPress plugins can provide a user interface for managing comment form fields. Plugins like "Custom Comment Fields" or "WP Comment Fields" can often achieve these modifications without writing code.
Important Considerations
- Child Theme: Always use a child theme when adding custom code to prevent your changes from being overwritten by theme updates.
- Theme Updates: The Twenty Twenty theme is regularly updated. The methods described here are standard WordPress practices and are likely to remain functional after updates, but it's good practice to test after a theme update.
- Plugin Conflicts: Some changes, particularly those involving comment pagination or the display of HTML, are controlled by WordPress core, not the theme. For issues like allowing HTML in comments, solutions would need to be applied at the WordPress level.
By following these methods, you can tailor the Twenty Twenty comment section to better fit your website's design and functionality needs.
Related Support Threads Support
-
Leave Reply – changing the section?https://wordpress.org/support/topic/leave-reply-changing-the-section/
-
2020 Theme Sharing Buttons and Comment Formhttps://wordpress.org/support/topic/2020-theme-sharing-buttons-and-comment-form/
-
renovate comments sectionhttps://wordpress.org/support/topic/renovate-comments-section/
-
How to remove website column from Comments sectionhttps://wordpress.org/support/topic/how-to-remove-website-column-from-comments-section/
-
Reply to Comments still visiblehttps://wordpress.org/support/topic/reply-to-comments-still-visible/
-
Widget Sidebarhttps://wordpress.org/support/topic/widget-sidebar-11/
-
2020 theme Customizehttps://wordpress.org/support/topic/2020-theme-customize/
-
How to add ‘Click to edit this widget’ button to widgets ?https://wordpress.org/support/topic/how-to-add-click-to-edit-this-widget-button-to-widgets/
-
theme is scrolling to another location when a link is activatedhttps://wordpress.org/support/topic/theme-is-scrolling-to-another-location-when-a-link-is-activated-2/
-
Editing comment section in Twenty Twenty themehttps://wordpress.org/support/topic/editing-comment-section-in-twenty-twenty-theme-2/
-
SIDEBAR WANTED!https://wordpress.org/support/topic/sidebar-wanted/
-
Adding a widget or menu in posts before commentshttps://wordpress.org/support/topic/adding-a-widget-or-menu-in-posts-before-comments/
-
Customize Commenthttps://wordpress.org/support/topic/customize-comment/
-
Addtoany button alignmenthttps://wordpress.org/support/topic/addtoany-button-alignment/
-
commentshttps://wordpress.org/support/topic/comments-277/
-
Allow HTML Tags in Commenthttps://wordpress.org/support/topic/allow-html-tags-in-comment/
-
How to display comments in reverse order with pagination?https://wordpress.org/support/topic/how-to-display-comments-in-reverse-order-with-pagination-3/
-
Automatic add reusable blockshttps://wordpress.org/support/topic/automatic-add-reusable-blocks-2/