如何在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.

WordPress带有内置的注释系统 ,可让您围绕内容进行生动的讨论。 默认情况下,注释区域显示4个字段(名称,电子邮件,网站地址和消息)。 最近,我们的一位用户问我们是否可以将自己的自定义字段添加到WordPress注释表单中。 答案是肯定的。 在本文中,我们将向您展示如何在WordPress的注释表单中添加自定义字段。

影片教学 (Video Tutorial)

演示地址

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.

您需要做的第一件事是安装并激活WordPress Comments Fields 。 激活后,该插件将在您的WordPress菜单中添加一个名为“注释字段”的新菜单项。

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

除此之外,您还可以添加描述文本,错误消息,并将其设置为必填字段。 最后,您还可以将CSS类添加到每个自定义字段,以便您可以根据需要修改其外观(请参阅有关如何设置WordPress注释表单样式的指南)。

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.

自定义字段将出现在评论文本区域之前。 您可以使用添加CSS类来调整自定义字段的外观。

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.

您还可以在WordPress管理区域的评论页面上看到在这些字段中输入的数据。

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.

我们希望本文能帮助您将自定义字段添加到WordPress中的注释表单。 您可能还想看看我们的有关如何设置WordPress注释布局样式的教程。

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+.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterGoogle+上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-add-custom-fields-to-comments-form-in-wordpress/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值