If you have enabled the build-in comments section in your WordPress site and want to modify it, you’ve come to the right place. Customizing the WordPress comments form is easy with the corresponding WordPress comments form hooks. You can add different content before or after the comments form or even after the form fields and above the Post comment button.
This visual guide for the WordPress comment form hooks will help you easily understand and find the right spot to add your custom content.
WordPress Comments – Visual Hook Guide
1. If the user is NOT logged in
The following hooks are available when the user is not logged in and is allowed to comment on the post and the comments are not closed:
comment_form_before
Leave A Comment
comment_form_top
comment_form_before_fields
comment_form_after_fields
comment_form
comment_form_after
2. If the user is logged in
If you are logged in, there are fewer hooks available since the name, email and website fields are not needed. The following hooks are not available when the user is logged in:
- form_comment_before_fields
- form_comment_after fields
3. User is not logged and “Users must be registered and logged in to comment” is activated
All unregistered users will see the following comment form with an additional hook: comment_form_must_log_in_after.
comment_form_before
comment_form_after
WordPress Comments Hooks
Here is a sum of the total seven WordPress comments hooks:
- comment_form_before
- comment_form_top
- comment_form_before_fields
- comment_form_after_fields
- comment_form
- comment_form_must_log_in_after
- comment_form_after
Learn more about Comments in WordPress.
Related Articles
If you enjoyed reading this, then please explore our other articles below:
Is there a way to add a comment form to each woocommerce order page?
I would like a discussion/comment box at the end of each woocommerce order. I cannot opt to add in discussion/comment area like on the WP default posts & pages. I’m not sure which file woocommerce orders falls in with the GeneratePress theme. I looked through most of the files but didn’t see an option to support = comments. I researched there is a way to add Orders as a custom post type for comments.
Here’s the beginning of a code the I tied: add_action( ‘woocommerce_order_details_after_order_table’, ‘comment_form’ );
function comment_form( $args = array(), $post_id = null ) {
if ( null === $post_id ) {