Hi Im having trouble adding my custom fields to the default twentyten comment form. This is what im doing in the functions.php file of my child theme- am i forgetting something?
// Customise comment form for garage-sales page
if ( is_page('my-page') ):
add_filter('comment_form_default_fields','my_comment');
function my_comment($fields) {
// New fields
$fields['date'] = '<label>Date:</label><input type="text" name="date" value="'.(!empty($_POST['date']) ? $_POST['date'] : '').'" />';
$fields['start_time'] = '<label>Start time:</label><input type="text" name="start_time" value="'.(!empty($_POST['start_date']) ? $_POST['start_date'] : '').'" />';
$fields['end_time'] = '<label>End time:</label><input type="text" name="end_time" value="'.(!empty($_POST['start_date']) ? $_POST['start_date'] : '').'" />';
$fields['early_birds'] = '<label>No early birds?:</label><input type="checkbox" name="early_birds" '.(isset($_POST['early_birds']) ? 'checked' : '').' />';
$fields['bad_weather'] = '<label>Bad weather?:</label><input type="checkbox" name="bad_weather" '.(isset($_POST['bad_weather']) ? 'checked' : '').' />';
// Remove unwanted default fields
unset($fields['url']);
return $fields;
}
endif;
I had a similar problem where the filter ‘comment_form_default_fields’ is what displays on the comment form when you are not logged in.
The ‘comment_form_field_comment’ filter contains the code for when you are logged in.
Hope that made sense and helps
You have to point priority probably more than 10 like this
It can be other filters on this hook in the parent theme or plugins which are invoked after your code.