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

Leave A Comment

You must be logged in to post a comment.

comment_form_must_log_in_after

comment_form_after

WordPress Comments Hooks

Here is a sum of the total seven WordPress comments hooks:

  1. comment_form_before
  2. comment_form_top
  3. comment_form_before_fields
  4. comment_form_after_fields
  5. comment_form
  6. comment_form_must_log_in_after
  7. comment_form_after

Learn more about Comments in WordPress.




Recent Articles

Blog Categories

Comments

Leave a comment
  1. Alex August 12, 2020 at 8:05 am - Reply

    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 ) {

Leave a Reply

Comment policy: We love comments and appreciate the time that readers spend to share ideas and give feedback. However, all comments are manually moderated and those deemed to be spam or solely promotional will be deleted.