Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Add Custom Fields to Comments Form in WordPress

WordPress comes with a built-in comment system which allows you to have lively discussion around your content. By default, the comment area shows 4 fields (name, email, website address, and message). Recently one of our users asked us if they could add their own custom fields to WordPress comments form. The answer of course is yes. In this article, we will show you how to add custom fields to comments form in WordPress.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

First thing you need to do is install and activate the WordPress Comments Fields. Upon activation, the plugin will add a new menu item labeled ‘Comments Fields’ in your WordPress menu.

You need click on it to go to the plugins settings screen where you can add custom fields to the comment form.

Drag and drop input fields to the form

Currently, there are four types of custom fields you can add to your comment form (text input, select box, radio buttons, and checkboxes).

Simply drag a field and add it to the area labeled ‘Drag form fields here’. You will be able to see the options for each field as soon as you drop it in the editable area.

Configuring your custom comment form field

Each field usually has a title which will be displayed as the custom field label on your comment form. Data name is the name of the form field which needs to be all lower case and will be used to store the data.

Apart from that, you can also add a description text, an error message, and make a field required. Lastly you can also add a CSS class to each custom field, so that you can modify its appearance if needed (See our guide on how to style your WordPress comment form).

You can add as many custom fields as you want. Once you are done, simply click on the Save all changes button to store your settings.

The custom fields will appear just before the comment textarea. You can use the CSS class you added to adjust the appearance of the custom field.

Custom fields in WordPress comment form

The data entered by users in the custom fields will appear below their comments as comment meta.

Custom fields in the comment form will appear as comment meta

You will also be able to see the data entered into these fields on the comments page in your WordPress admin area.

Custom fields appearing as comment meta in the admin area

We hope this article helped you add custom fields to comments form in WordPress. You may also want to take a look at our tutorial on how to style WordPress comments layout.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Google+.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

10 CommentsLeave a Reply

  1. This plugin hasn’t been update in 2 years. Is there any trustworthy aka. actively maintained solution? Cheers!

    • While we don’t have a specific plugin we would recommend at the moment, you could take a look at advanced custom fields for another possible method. We will be sure to look for other plugin options

      Admin

  2. Thanks for this great post.

    I want to add a conditional php code in the comments template source file. The idea is to check the value of a custom field chosen by a user and then to display some text depending on it ((For example, ” if (CUSTOM_Field = ‘A’) { echo ‘…”; } else { echo ‘…’; }). How can I retrieve the custom field?

  3. Helpful tutorial…I love this plugin. But is there a way to manually code this without installing this plugin?

    Thanks for your support.

  4. Nice tutorial! Everything works fine, but now I am looking for an option to ONLY display the extra content of the comment form on a specific page, NOT on all pages.

    Does anyboday have an idea of how this can be arranged?

    Thanks!

    • hi,
      Maybe my solution is not universal but I had to realize the same feature on my web site.
      I just added a custom field to the whole comment form for all the pages and hide this field in my css. Then showed it for a body page class.
      E.g:
      .custom_field_name{display: none}
      body.customer-feedback .custom_field_name{display: block}
      If your field must be required, just make it NOT required in the plugin admin area and do a custom field check with javascript in your page.php theme file,
      E.g:
      <? echo(is_page('customer-feedback')) ? 'if(document.querySelector(‘.custom_field_name’).value == ”) alert(‘Please fill Custom Field’);’ : ” ?>

  5. Thanks for this post! I am wondering if this plugin will allow you to change the phrase “Leave a Reply” to something else like “Share Your Thoughts.” I have looked around and not seen an easy fix/plugin for this. I’ve noticed that in wordpress.com sites you can change it under “Settings” but not in .orgs. Any info would be appreciated. I’m using a child theme and could add code easily in a function.php file, but other than that I’m still pretty new to all this. Thanks!

  6. I actually have a question about something other than this regarding comments. I wrote a post on my (twenty twelve theme) blog yesterday and then shared it on my facebook (personal) page. It showed up on FB with the title of the blog -a straight vertical line- then the title of my website. In the middle of the first sentence was the “Leave a reply.” It really looked messed up. I looked all over the coding so I could cut and paste it at the bottom. It wasn’t there. I suspect it is in the Editor (under Appearnces) coding. But I am afraid to mess with that. Can you please (!) help me with this?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.