Hi Harry,
did you find a solution to your problem? I need to add the same to my comments form.
Thanks
Jane
Moderator
t-p
(@t-p)
Thanks for the links t-p. I’ve had a read through, I’m not great with code and I;ve managed to come up with this:
<?php
add_filter('comment_form_default_fields','my_fields');
function my_fields($fields) {
// New fields
$fields['title'] = '<label>Title:</label><input type="text" name="title" value="'.(!empty($_POST['title']) ? $_POST['title'] : '').'" />';
$fields['tracks'] = '<label>Tracks:</label><input type="text" name="tracks" value="'.(!empty($_POST['tracks']) ? $_POST['tracks'] : '').'" />';
$fields['format'] = '<label>Format:</label><input type="text" name="format" value="'.(!empty($_POST['format']) ? $_POST['format'] : '').'" />';
return $fields;
}
?>
It shows on the comments form on my website and I can fill in the fields but when I submit only the name/website/comment show up and the custom fields dont. Is there something else I need to do?
Thanks
Jane
(@harryatkins)
15 years, 6 months ago
Hi,
I’m trying to add 2 more fields to the default WordPress Comment form, and have them appear in the comments as well, The first one I’m adding is a radio button selection out of 10 and the second is a drop down list of choices. I can add the html into the ‘Comments.php’ file but don’t know how to get what the user has entered to appear in the comments, I’ve only found one plugin that can help and this doesn’t work with the latest version of WordPress (3.0.1) If anyone could help me out it would be very much appreciated.
Many thanks in advance
Harry Atkins