Skip to main content
1 of 2
agis
  • 421
  • 5
  • 13
  • 25

custom comment fields on CPT

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' ) ) {

What's wrong with my code? Thanks!

agis
  • 421
  • 5
  • 13
  • 25