I want to create few comments custom fields for my CPT and remove the default ones.
I will have just two custom fields more exactly 2 radio inputs.
Here is my code:
function debate_comment_fields( $fields ) {
if( is_singular( 'debate' ) ) {
$fields['url'] = '';
$fields['author'] = '';
$fields['email'] = '';
$fields['first'] = '<p class="comment-form-first"><label for="first">' .
__( 'HTML5' ) .
'</label>' .
'<input id="first" name="category" type="radio" value="'.get_post_meta($post->ID, 'agree', true).'" /></p>';
$fields['second'] = '<p class="comment-form-second"><label for="second">' .
__( 'FLASH' ) .
'</label>' .
'<input id="second" name="category" type="radio" value="'.get_post_meta($post->ID, 'disagree', true).'" /></p>';
return $fields;
}
}
add_filter('comment_form_default_fields','debate_comment_fields');
The problem is that on my default blog posts the url, author and email fields are removed also and I'm expecting to see them there because I've added if( is_singular( 'debate' ) ) {
And if I submit a comment inside my CPT I get: ERROR: please fill the required fields (name, email).
It seems that it's still asking me for those fields.
What's wrong with my code? Thanks!